bug in logarithm()

Martin Koeppe mkoeppe@gmx.de
Thu Oct 18 00:10:00 GMT 2007



Hi Jeff,

On Wed, 17 Oct 2007, Jeff Johnston wrote:

>> I just found a bug (or at least a discrepancy between doc and src) in 
>> newlib's libm, files mathfp/s_logarithm.c and mathfp/sf_logarithm.c:
>> 
>> There the docs at the beginning of the files say, log(0) returns -Inf, what 
>> the gawk test suite would also expect btw, but clearly the implementation 
>> doesn't return -Inf, but NaN instead.
>> 
>> Martin
> A fix has been made.  Thanks.

the fix isn't quite right. log(-1) should still return nan. In 
particular log(x) should return:

x==nan or x<0.0 : errno=EDOM,   return nan

x==0.0 :          errno=ERANGE, return -inf

x>0.0 :           return log(x)


Martin



More information about the Newlib mailing list