Re: flexponent in sample implementation returns different value from logb
William D Clinger 18 Aug 2017 14:14 UTC
Takashi Kato wrote:
> (flexponent 0.04419417382415922) returns -4.0 but
> logb(0.04419417382415922) return -5
>
> Since SRFI says it's equivalent of logb, can I assume the value
> returned by logb is correct?
I suspect so. The C99 specification of logb says it returns the
"signed integral part" of log_r|arg|, where r is the FLT_RADIX,
which the sample implementation assumes to be 2. Evidently the
"signed integral part" is to be obtained by taking the floor
rather than truncating as in the sample implementation.
Note that (flnormalized-fraction-exponent 0.04419417382415922)
returns -4 as its second value, which is correct.
Within the next few days, probably tomorrow, I will submit a pull
request that fixes the flexponent bug along with a few portability
bugs I discovered by testing with non-IEEE-754 arithmetic.
Will