delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/01/11/12:26:47

Date: Thu, 11 Jan 2001 19:25:04 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: djgpp-workers AT delorie DOT com
Subject: Weird results of log( -1.0 ) with libm.a and without libm.a (fwd)
Message-ID: <Pine.SUN.3.91.1010111191955.20014B-100000@is>
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019