bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: printf "%010a" Inf/NaN and FreeBSD


From: Eric Blake
Subject: Re: printf "%010a" Inf/NaN and FreeBSD
Date: Thu, 05 Apr 2007 06:16:31 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.10) Gecko/20070221 Thunderbird/1.5.0.10 Mnenhy/0.7.5.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Bruno Haible on 4/5/2007 5:14 AM:
> Eric Blake wrote:
>>> I find glibc's output more sensible, since strtod will accept it, while
>>> strtod will not grok "0000000inf". But FreeBSD appears to be closer to
>>> the POSIX wording, I won't count it as a FreeBSD bug.
>> I would, though.  POSIX allows "inf" vs. "infinity", but unless %010f
>> prints "0000000inf", I don't think %010a should do so either, because
>> POSIX was clear that "A double argument representing an infinity or NaN
>> shall be converted in the style of an f or F conversion specifier."
> 
> There is also the description of the '0' flag, which says the same for 'a'
> as for 'f':
>    "For d , i , o , u , x , X , a , A , e , E , f , F , g , and G conversion
>     specifiers, leading zeros (following any indication of sign or base) are
>     used to pad to the field width; no space padding is performed."

Yes, I read that too.  And with %a, "0000000nan" has no indication of
base, so it violates the above statement (the leading zeros must follow
the 0x, but with nan, there is no 0x).  Your argument about strtod being
able to parse printf results is also an important factor, because real
code expects that to work.  That's now three reasons why I think FreeBSD's
behavior is wrong.

> 
> POSIX doesn't guarantee it. And on systems where the number of mantissa bits
> (including the hidden bit) is not congruent to 1 modulo 4, the printf
> implementor might choose to map the bits in a predefined way,

Fair enough.  I won't make you do it if platforms don't do it; it was only
a quality-of-implementation suggestion.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGFOif84KuGfSFAYARAuPvAKCknbTLdpKl4dCd04N7SNWk9XgEWwCgpQFO
sQQHk9kGjC37c14Cadq4/Ng=
=M06x
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]