[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: why 0.1+0.2-0.3~=0
- From: Rena <hyperhacker@...>
- Date: Tue, 13 Mar 2012 20:38:13 -0600
On Tue, Mar 13, 2012 at 04:59, Robert Virding
<robert.virding@erlang-solutions.com> wrote:
>
> ----- Original Message -----
>> On Tue, Mar 13, 2012 at 12:37, Karol Bielecki
>> <karol.bielecki@tagmet.com.pl> wrote:
>> > in my program and on the website http://www.lua.org/cgi-bin/demo
>> >
>> >
>> > tmp=0.1+0.2-0.3
>> > print(tmp)
>> >
>> > gives
>> >
>> > 5.5511151231258e-17
>> >
>>
>> http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html
>
> That is a wonderful paper which everyone definitely should read if they ever come near floating point arithmetic.
>
> Robert
>
Seconded. If you ever deal with floating point (and Lua uses it
extensively), you need to understand how it works and what pitfalls to
watch out for, and that article explains them very well.
--
Sent from my toaster.