[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gawk] How to print the just enough number digits so the machine
From: |
Eli Zaretskii |
Subject: |
Re: [bug-gawk] How to print the just enough number digits so the machine representation of the number does not change? |
Date: |
Mon, 08 Oct 2012 14:42:39 +0200 |
> Date: Mon, 8 Oct 2012 06:03:10 -0600 (MDT)
> From: "Nelson H. F. Beebe" <address@hidden>
> Cc: address@hidden, Peng Yu <address@hidden>, address@hidden
>
> I beg to differ on the number of digits required for binary to decimal
> conversion.
Sorry, but I don't understand the bottom line. What does this mean in
terms of answer to the OP's question? Is my suggestion to use %.20g
incorrect, and if so, what is the correct answer?
> hoc> matula(53)
> 17
That's what I said, IMO.
> hoc> goldberg(16)
> 55
>
> Notice that the two functions are not mutually symmetric: 16 decimal digits
> needs two more bits than the 64-bit binary format can supply.
Isn't one of these bits hidden?
More importantly, I still don't see the practical consequences.
Suppose I used 20-digit format to print a 'double', then read it with
%f -- are you saying the extra bits will somehow affect the machine
representation of the result after reading? If so, how, and could you
show an example of this, please?
> The default output format in decimal for a 32-bit IEEE binary type should be
> 9 digits. The 32-bit IEEE decimal type needs 25 bits for correct round-trip
> conversion.
The OP asked (albeit implicitly) about 'double', not 'float'.
Thanks.