*BSD News Article 32473


Return to BSD News archive

Xref: sserve comp.os.386bsd.bugs:2314 misc.test:42416
Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!yarrina.connect.com.au!warrane.connect.com.au!kralizec.zeta.org.au!not-for-mail
From: bde@kralizec.zeta.org.au (Bruce Evans)
Newsgroups: comp.os.386bsd.bugs,misc.test
Subject: Re: float->string bug in FreeBSD 1.1 release
Date: 3 Jul 1994 13:53:50 +1000
Organization: Kralizec Dialup Unix Sydney - +61-2-837-1183, v.32bis v.42bis
Lines: 27
Message-ID: <2v5coe$7cs@kralizec.zeta.org.au>
References: <KARRELS.94Jul2120712@elf.mcs.anl.gov>
NNTP-Posting-Host: kralizec.zeta.org.au

In article <KARRELS.94Jul2120712@elf.mcs.anl.gov>,
Edward L. Karrels <karrels@mcs.anl.gov> wrote:
>FreeBSD 1.1 seems to have problems converting NaN floats to strings.
>Other machines just convert them to "NaN", but I'm getting floating-point
>exceptions.  Doubles seems OK, though I haven't really tested them.  I just

The default FreeBSD i387 exception mask forces a SIGFPE if you do anything
with a signaling NaN except load it as a 10-byte long double (an operation
that is not available in C with gcc-2.4.5 since long doubles are only 8
bytes).

>  z.m.mantissa = 0;		/* +infinity */
>  z.m.exponent = 255;
>  z.m.sign     = 0;
>
>  printf( "z = %g\n", z.f );
>  
>  z.m.mantissa = 1;		/* NaN */
>
>  printf( "z = %g\n", z.f );

Here z.f is a signaling NaN and causes an invalid operand exception when
loaded, before printf has a chance to look at it.  Loading a double
signaling NaN would trap too.  Only the position of the "quiet" bit is
really different for doubles.
-- 
Bruce Evans  bde@kralizec.zeta.org.au