lua-users home
lua-l archive

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


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