[PATCH] manual: logb(x) is floor(log2(fabs(x)))
Morten Welinder
mwelinder@gmail.com
Tue Mar 5 13:16:09 GMT 2024
> No, it isn't necessarily equal. The code floor (log2 (fabs ((x)))
> can give an incorrect result due to rounding if x is just before
> a power of 2, in particular if x is large.
Right you are.
However, the formula is meant as an explanation, not a C code
substitute, so I think a bit of rewording can fix it. Something like
...works like "floor (log2 (fabs (x)))" if that formula is computed
without rounding of intermediate values.
Same story as fma really.
M.
More information about the Libc-alpha
mailing list