[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Floating point inaccuracies
- From: bb <bblochl@...>
- Date: Mon, 29 Nov 2010 12:29:00 +0100
Am 29.11.2010 11:03, schrieb Luiz Henrique de Figueiredo:
You do. The code below prints true.
a=1/3
b=3*a print(b==1)
b=a+a+a print(b==1)
b=(a+a)+a print(b==1)
b=a+(a+a) print(b==1)
To have some fun - have you tried this modified but equal version?
a=(1+1/3)-1
b=3*a print(b==1)
b=a+a+a print(b==1)
b=(a+a)+a print(b==1)
b=a+(a+a) print(b==1)
The difference obviously is in the 16th digit
a=((1+1/3)-1)-1/3
print(string.format("a = %.20f", a))
a = -0.00000000000000005551