Pseudo code:
function get_lowest_bit(in input, out bit_pos) returns true if input is not 0, false otherwise
for bit_pos = 0 to max_bits-1
if (input bit_and (1 left_shift bit_pos) not_equal 0
return true
end if
end for
return false
end function
Likewise for the upper bit.
Cheers
Andi
PS: I assume this is a homework, that's why I do not give you the C# solution and leave the exercise for the highest bit for you ;-)