-----Original Message-----
From: Segher Boessenkool
Sent: Monday, July 04, 2016 1:25 PM
To: sisyphus1@xxxxxxxxxxxxxxx
Cc: gcc-help@xxxxxxxxxxx
Subject: Re: strtold("inf",NULL) returns a NaN
On Mon, Jul 04, 2016 at 11:45:42AM +1000, sisyphus1@xxxxxxxxxxxxxxx wrote:
ld is: 7fff8000000000000000
This is +Inf in 80-bit 8087 format.
After I had posted I started having second thoughts as to whether my
summation was correct.
f128 is: 7fff8000000000000000000000000000
This is a NaN in standard format (Inf would be
7fff0000000000000000000000000000).
It's only when this long double value is cast to __float128 that it
behaves
as a NaN.
Where to from here ?
Look at the generated machine code for the cast? The value returned from
strtold looks correct.
Yes, if strtold is returning correctly && __float128
7fff8000000000000000000000000000 is Nan, then the bug must be in the cast.
One thing I do know is that appendix A of my 2010 edition of K&R's "The C
Programming Language" (2nd edition) tells me:
[quote]
A6.4 Floating Types
When a less precise floating point value is converted to an equally or more
precise floating type, the value is unchanged.
[end quote]
but that aint happening here.
Thanks, Segher.
Cheers,
Rob