chickadee » math » fplog2

fplog2 xprocedure
x
flonum

Computes the base-2 log of x more accurately than (/ (fplog x) (fplog 2.0)). In particular, (fplog2 x) is correct for any power of two x.

Examples:

> (fplog2 4.5)
2.169925001442312
> (/ (fplog (fpexp2 -1066.0)) (fplog 2.0))
-1066.0000000000002
> (fplog2 (fpexp2 -1066.0))
-1066.0

Maximum observed error is 0.5006 ulps (see fpulp), but is almost always no more than 0.5 (i.e. it is almost always correct).