www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/06/09/14:46:54

Date: Wed, 09 Jun 1999 13:44:16 -0500
From: Eric Rudd <rudd AT cyberoptics DOT com>
Subject: Re: libm sources from cyberoptics
To: djgpp-workers AT delorie DOT com
Message-id: <375EB600.979DA70D@cyberoptics.com>
Organization: CyberOptics
MIME-version: 1.0
X-Mailer: Mozilla 4.05 [en] (Win95; U)
References: <Pine DOT SUN DOT 3 DOT 91 DOT 990609113455 DOT 11862J-100000 AT is>
Reply-To: djgpp-workers AT delorie DOT com

Eli Zaretskii wrote:

> Infinites should produce ERANGE, but I think denormals shouldn't.
> Denormals are simply the last resort of overcoming the limitations of
> the machine representation, and at least printf-family functions have
> no problems with them.

I will take a look at the code, to see if it's not too difficult to change.
However, it introduces an asymmetry into the tests, which complicates them.
There's still the problem of situations like exp(-1.E10), which underflows to
zero.  As Hauser says in his paper
http://cch.loria.fr/documentation/IEEE754/ACM/hauser.pdf,

"If all underflows are signaled as exceptional, most such signals will be false
alarms because the underflows would have been absorbed in subsequent additions,
anyway.  Yet any unsignaled underflow has the potential to introduce devastating
inaccuracies in a calculation."

> I vote for a positive zero as the result of sqrt(-0.).

My reasoning for sqrt(-0.) = NaN went as follows:

   sqrt(-0.) = sqrt((-1.)*(+0.))
             = sqrt(-1.)*sqrt(+0.)
             = NaN*sqrt(+0.)
             = NaN*(+0.)
             = NaN,

*not* sqrt(-0.) = +/-0., even though, arguably, one has

   |sqrt(-0.)| = sqrt(|-0.|)
               = 0.

I would be interested in others' experience with such situations.

> ANSI C says that a "domain error occurs if the result cannot be
> represented when x is zero and y is less than or equal to zero".  Is
> 0^0 unrepresentable?

Since the mathematical limit does not exist, I would argue that 0^0 is
unrepresentable, except by NaN.  It would be very easy to modify the code to
return pow(0.,0.)=1. without setting errno, but I felt that pow(0., 0.) indicated
a probable programming error that needed to be flagged.

-Eric Rudd

- Raw text -


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