What is a good way to bin float precision numbers? something like this, but perhaps more efficient?
x = 1;
for i = 0,size-1 { // loop over number of bins
if
I'll answer this question, I think it might help you:
"Given a number x, what is the exponent when x is written in scientific notation. For example, if x is .007, the exponent is -3 (7x10^-3)."
So, x = a * 10^b, with 1 <= a < 10. We solve for b.
Let's take the log (base 10) of both sides
Now b is an integer, and 0 <= log(a) < 1, so log(a) is really just the fractional part of log(x). So, we can just drop the fractional part by rounding log(x) down.
When x = .007, b = floor(-2.15) = -3 as expected
I think the C code would be int b = (int) floor( log10( x ) )