Subject: Re: handling very small doubles
To: None <port-pc532@netbsd.org>
From: Jon Buller <jonb@metronet.com>
List: port-pc532
Date: 09/15/1998 17:44:06
[ Meant to send this to Matthias, and CC: port-pc532, but I missed the
  port-pc532 line, guess I'll just send it to the list now.  If anyone
  can think of something I missed, I'd appreciate hearing about it. ]

Matthias Pfaller <leo@dachau.marco.de> wrote:

> Jon Buller wrote:
> > However, there appears to be a problem with scanf, which may be causing
> > some of the problems I'm seeing.  In particular, I tried the following:
> > 
> > #include <stdio.h>
> > #define DBL_MIN         2.2250738585072014E-308
> > void main () {
> >   double x;
> >   scanf ("%g", &x);
> >   printf ("%g   %g %d %d\n", DBL_MIN, x, DBL_MIN == x, x == 0.0);
> > }
> > 
> > When I ran it, I cut and pasted the DBL_MIN value and it printed:
> > 
> > 2.22507e-308   6.79039e-313 0 0
> > 
> > Has anyone seen this before, (or already fixed it?)
> 
> I just tried this on a NetBSD/i386 box (which has the same floating
> point format as the ns32k) and the result is:
> 
> 2.22507e-308   6.79039e-313 0 0
> 
> So at least this is not NetBSD/pc532 specific.

Hmmm, that means something else is wrong, since someone on the PostgreSQL
list said that that use of DBL_MIN worked with PostgreSQL on NetBSD/i386.

I first thought that it was turning a denormalized number into Zero.
My test case proved that wrong, but turned up a bug in scanf, but that's
not port-specific, and my problem should be.

Guess I need to sleep on this one a bit...
Jon