This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: return value of log()


> From: Corinna Vinschen <cygwin@cygwin.com>
> 
> On Wed, Mar 07, 2001 at 07:10:53PM +0900, Kenta MURATA wrote:
> > 
> > I can't understand that log(x) returns -HUGE_VAL if x < 0.
> > Becaus, IEEE definition returns NaN.
> > 
> > Why adopt this implementation?

Perhaps because that's how log() on UNIX behaved traditionally,
before IEEE floating point was defined. The C Standard says that
the return value is implementation-defined in this case - that
is, the implementation can return anything it likes as long as
it documents it.

> In the newlib sources I found:
> 
>   /* Check for domain error here. */
>   if (x <= 0.0)
>     {
>       errno = ERANGE;
>       return (z_notanum.d);
>     }

Now that is interesting - C requires errno to be set to EDOM
in this case (and for all other domain errors in the <math.h>
functions) and UNIXes have traditionally set it to EDOM.

Looks like there might be a bug in the setting of errno even
though there's no problem with the value returned.


--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]