bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: it looks like bug:(


From: David Kastrup
Subject: Re: it looks like bug:(
Date: Fri, 19 Oct 2007 10:09:03 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/23.0.50 (gnu/linux)

"Andrew J. Schorr" <address@hidden> writes:

> On Thu, Oct 18, 2007 at 09:28:27AM -0700, Micah Cowan wrote:
>> Try changing ‘print w’ to ‘printf("%.24g\n", w)’, or just set OFMT to a
>> value of "%.24g". OFMT is the conversion specification used to convert
>> numbers to strings for output; CONVFMT is used to convert numbers to
>> strings when required by an expression.
>
> Actually, the IEEE 754 double-precision floating-point format that
> gawk typically uses has about 16 digits of precision, so printing
> "%.24g" goes well beyond the actual precision of the floating-point
> representation.

Almost.  To get an exact value representation, you need as many
decimal digits as there are binary digits.  To get an unambiguously
close representation (meaning that the closest representable binary
value is the intended one), of course, fewer digits suffice.

-- 
David Kastrup





reply via email to

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