www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/01/11/12:21:41

Date: Thu, 11 Jan 2001 19:19:48 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Tanes Sriviroolchai <Tanes DOT Sriviroolchai AT Thailand DOT NCR DOT COM>
cc: djgpp AT delorie DOT com
Subject: Re: Weird results of log( -1.0 ) with libm.a and without libm.a
In-Reply-To: <3a5d81c9@rpc1284.daytonoh.ncr.com>
Message-ID: <Pine.SUN.3.91.1010111191648.20014A-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Thu, 11 Jan 2001, Tanes Sriviroolchai wrote:

> 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

This is what log() from libm.a is documented to produce.  Here's the 
relevant excerpt from libm.info:

  Return Value
  -------------
     Normally, returns the calculated value.  When X is zero, the
  returned value is `-HUGE_VAL' and `errno' is set to `ERANGE'.  When X
  is negative, the returned value is `-HUGE_VAL' and `errno' is set to
  `EDOM'.  You can control the error behavior via `matherr'.

- Raw text -


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