This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


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

Re: [ezolt@perf.zko.dec.com] libc/1882: atof("NaN") doesn't return quiet NaN and doesn't detect IEEE mode.


Richard,

>On Mon, Sep 04, 2000 at 11:11:59AM +0200, Andreas Jaeger wrote:
>> When compiling with -ieee (with both Gcc & ccc), perl works just fine.
>> Without -ieee & -mieee, there is a floating point exception.  This
>> appears to depend on the value that atof (& strtod) returns when passed
>> a "NaN". 

>What do you expect, anyway?  I expect exactly this result.

If the user has specified that he/she does not want ieee compliance, we
should return what makes the most sense for the user, by avoiding
unneeded FPEs.  atof("NaN") should evaluate to 0. 

Older versions of GNU libc returned zero all the time.

Having a "more-accurate" atof is fine, but why cause unneeded FPEs, when the
user KNOWS that he is not in ieee mode? 

>> 1) GNU Libc's atof (and strtod) is not returning a quiet NaN.
>Yes it is.  But without -mieee, even a quiet nan results in SIGFPE.

The SIGFPE is only part of the problem.  The glibc is not returning
what hardware would return (0xfff8000000000000). 

According to one of our compiler engineer's here: 

(1) The Alpha architecture defines a lot of different bit patterns to
be quiet NaNs.  0x7ff8000000000000 is a quiet NaN.  We would probably
prefer that atof("NaN") return the *canonical* quiet NaN
(0xfff8000000000000).  We should suggest that Alpha Linux libc do this
since the hardware produces the canonical quiet NaN when it needs a
quiet NaN value and it would be valuable that atof("NaN") produce the
same bit pattern as the hardware.


>> It would also be nice if the Alpha Linux libc figured out the
>> -mieee setting of its callers.  There is no standard requiring this
>> but we should suggest the behavior to the Alpha Linux libc maintainers.

>Yes, that would be nice, I suppose.  You'll want to play silly games with 
>#ifndef _IEEE_FP
>double atof(const char *) __asm__("__noieee_atof");
>#else
>double atof(const char *);
>#endif
>Patches accepted.
>r~

Tru64 determines at run-time what ieee mode is set and picks the appropriate
function.  Can this be done in Glibc? 

--Phil

Compaq:  High Performance Server Division/Benchmark Performance Engineering 
---------------- Alpha, The Fastest Processor on Earth --------------------
Phillip.Ezolt@compaq.com        |C|O|M|P|A|Q|        ezolt@perf.zko.dec.com
------------------- See the results at www.spec.org -----------------------

On 4 Sep 2000, Andreas Jaeger wrote:

> 
> Alpha glibc developers and users,
> 
> can you please have a look at the appended bug report?
> 
> Thanks,
> Andreas
> 
> 
> 


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