[Top][All Lists]

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

Re: gawk number to string bug

From: Eli Zaretskii
Subject: Re: gawk number to string bug
Date: Tue, 20 Dec 2005 00:50:21 +0200

> Date: Mon, 19 Dec 2005 17:12:55 -0500
> From: "Andrew J. Schorr" <address@hidden>
> Cc: address@hidden, address@hidden, address@hidden
> > I don't think you can trust a long-to-double conversion to be safe.
> > It could, for example, trigger a FP exception, whose effects are
> > practically unpredictable.
> Here is section of the ANSI C99 standard:

Hold it right there: if we need to cater only to C9x, then we could
convert to `long long' and be done with it.

The whole problem is that `long long' cannot be relied upon, because
C9x is not yet widespread enough.

>    2   When a value of integer type is converted to a real floating type, if
>    the value being converted can be represented exactly in the new type, it is
>    unchanged. If the value being converted is in the range of values that can
>    be represented but cannot be represented exactly, the result is either the
>    nearest higher or nearest lower representable value, chosen in an
>    implementation-defined manner. If the value being converted is outside the
>    range of values that can be represented, the behavior is undefined.
> There is no mention of floating-point exceptions.  Are you sure
> that a floating-point exception is possible here?

Some older systems tended to generate an INEXACT FP exception in such
cases, since you lose precision: a 64-bit IEEE double cannot store 19
significant digits.

reply via email to

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