nan or -nan?

Don nospam at nospam.com
Mon Nov 21 01:23:51 PST 2011


On 19.11.2011 01:22, Walter Bright wrote:
> On 11/18/2011 1:32 PM, Paul D. Anderson wrote:
>> From the Decimal Arithmetic Specification
>> (http://speleotrove.com/decimal/decarith.pdf):
>>
>> "All special values may have a sign, as for finite numbers. The sign
>> of an
>> infinity is significant (that is, it is possible to have both positive
>> and
>> negative infinity), and the sign of a NaN has no meaning, although it
>> may be
>> considered part of the diagnostic information."
>
> Having no meaning means it is legitimate to not be concerned if the sign
> is toggled.

I'm not sure about that. They may simply be saying that it has no 
"physical" meaning, without saying that it has no meaningful semantics.
The behaviour is a bit strange, because x86 does define the sign of NaN 
for all operations.

If the sign doesn't have reliable semantics, we probably shouldn't be 
printing it. It just causes confusion. Personally, I think it would make 
more sense to only print the sign if you're also printing the payload. 
Maybe print -nan for %a format, but not for %f and %e.



More information about the Digitalmars-d mailing list