Mail Archives: djgpp-workers/2001/01/11/12:26:47
Someone complained about log() from libm producing -Inf for a negative
argument. It turns out that this is what the code is supposed to do, and
it is even documented in libm.info (type "info libm log").
Does anyone has an idea why this is the Right Thing to do?
---------- Forwarded message ----------
Date: Thu, 11 Jan 2001 16:49:21 +0700
From: Tanes Sriviroolchai <Tanes DOT Sriviroolchai AT Thailand DOT NCR DOT COM>
To: djgpp AT delorie DOT com
Newgroups: comp.os.msdos.djgpp
Subject: Weird results of log( -1.0 ) with libm.a and without libm.a
Hi,
I'm currently using DJGPP 2.03, gcc 2.95.2. The following short program
gives the different result when using libm.a and when not using libm.a.
#include <stdio.h>
#include <math.h>
main()
{
double y;
y = log( -1.0 );
printf( "%f\n", y );
return 0;
}
gcc -o test1.exe test1.c
when running you will get
NaN
This is expected result. However if I compile using
gcc -o test1.exe test1.c -lm
and then running, you will get
-Inf
Is there a report of this error before?
Regards,
Tanes Sriviroolchai
- Raw text -