Mail Archives: djgpp-workers/2003/04/07/14:01:16
Hello.
Martin Stromberg wrote:
>
> I said:
> > I propose all strto*() do use an unsigned long long to store the
> > mantissa (X) given in "nan(X)". If X > the maximum for float or
> > double, set the mantissa to all-ones (we clamp the value to the
> > maximum possible).
> >
> > This will make ``strtof(sprintf(s, "%d", NAN), NULL)'' return a
> > NaN.
>
> Am I confused or what? ``strtof(sprintf(s, "%d", NAN), NULL)'' would
> return a NaN even in my earlier posted implementation. The only
> difference is that the bits might be set differently.
>
> Do you have any preferences (clamping or masking)?
I think I prefer masking. It just "feels" better - probably because the NaN
will look more like NAN than nan(0x0) (or whatever).
> > If *printf() will handle NaN in a double separately from long doubles
> > this should make ``double value1 =
> > extreme_cpu_use_generating_unusual_nans();
> > double value2 = strtod(sprintf(s, "%d", value1), NULL)'' make the bit
> > pattern of value1 == the bit pattern of value2.
>
> This is sane though (IMO).
Yes, I think that the identity should hold for doubles and long doubles.
Whether that is true in reality is another question. (In other words, I have
to write some code. ;) )
Bye, Rich =]
--
Richard Dawe [ http://www.phekda.freeserve.co.uk/richdawe/ ]
- Raw text -