Subject: Re: scanf misses NAN and INF (patch to review)
To: Emmanuel Dreyfus <manu@NetBSD.org>
From: None <tlaronde@polynum.com>
List: tech-userlevel
Date: 04/04/2007 16:52:41
On Wed, Apr 04, 2007 at 10:30:43AM -0400, Greg Troxel wrote:
> manu@netbsd.org (Emmanuel Dreyfus) writes:
> 
> > Thor Lancelot Simon <tls@rek.tjls.com> wrote:
> >
> >> > What do you mean? The case where the object is not a float? I'm in case
> >> > CT_FLOAT, so this should be adressed...
> >> 
> >> No.  Not all floating-point formats have "not a number" or IEEE-style
> >> infinities, and we run on at least two machines where there is no
> >> floating point format that does, plus at least one where one of the
> >> available floating points doesn't (though we don't support it).
> >
> > Please give more details, I'm really clueless on this topic.
> 
> NaN is defined by IEEE 754.  The Vax has its own format, inherited from
> the PDP-11.  There's also an IBM floating point format, but I don't know
> if that's used on any machines NetBSD runs on.
> 
> This is an interesting historical perspective:
> 
>   http://www.cs.berkeley.edu/~wkahan/ieee754status/754story.html
> 
> So basically the point is that saying "There is such a thing as NaN." is
> only valid in the context of a particular floating point implemnetation.
> Maybe the nan-reading code needs to be ifdefed for HAVE_NAN, and I'd
> think that output code would have this same issue already.

A good "paper" too is included in NetBSD: 

man 3 math

;) it has some interesting notes about VAX and IEEE754, and about some
implementations details that are not widely documented (cf POSIX about
signals, and what is an error or not in floating point arithmetic in
IEEE754).
-- 
Thierry Laronde (Alceste) <tlaronde +AT+ polynum +dot+ com>
                 http://www.kergis.com/
Key fingerprint = 0FF7 E906 FBAF FE95 FD89  250D 52B1 AE95 6006 F40C