[erlang-questions] In Erlang , {1.1*1.1.} show me the answer is 1.2100000000000002, why?
Ola Bäckström
Ola.Backstrom@REDACTED
Mon Oct 27 12:45:25 CET 2014
The argument ”arguing that every language which does not write 1.2100000000000002 is lying to you.” is only valid if you encode floating point numbers in binary.
The rather cool 4-bit wide (!) microprocessor used in early HP calculators encoded both the mantissa and the exponent in 4-bit bcd. Thus it could exactly encode both 1.1 and 1.21, since it actually made the floating point calculations in decimal. No fancy algorithm for making the numbers “look nice” was needed.
My trusty old HP48 was both programmable and doing decimal as a human... so it didn’t have to lie.
(of course this does not mean that bcd gives higher precision in general. In fact it the opposite).
/Ola
From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Jesper Louis Andersen
Sent: den 26 oktober 2014 13:34
To: 张栋
Cc: Erlang (E-mail)
Subject: Re: [erlang-questions] In Erlang , {1.1*1.1.} show me the answer is 1.2100000000000002, why?
On Sun, Oct 26, 2014 at 8:24 AM, 张栋 <zd2559@REDACTED<mailto:zd2559@REDACTED>> wrote:
When I try some multiplication, I got the some unexpected answer about the following expression.
Hi!
In addition to what everyone else has said, you may want to search the archives. There is a couple of posts by Richard O. Keefe which explains this in great detail. If my memory serves, he actually ends up arguing that every language which does not write 1.2100000000000002 is lying to you.
--
J.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20141027/abbd6502/attachment.htm>
More information about the erlang-questions
mailing list