Numerical Search with 1-Bit Precision

I'm trying to do a numerical search and I want to find the number exactly. Here is some code to illustrate my question:

Code:

`long guessed_number, limit_number = 1000001;`

guessed_number = (long)(sqrt(my_output_double) * (double)some_long_int / some_double +0.5);

I want to find the largest value of guessed_number that is not greater than limit_number. I need 1-bit of precision. I'm trying to do a bisection search, but I'm not sure how to maximize the precision. I'm guessing that this must be a classic/standard problem and that references exist, no?