[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: arithmetics bug?
- From: Kevin Martin <kev82@...>
- Date: Sun, 31 Mar 2013 09:27:16 +0100
On 31 Mar 2013, at 09:06, vitaminx wrote:
> With this simple one-liner I can reproduce the following arithmetic error:
>
> for var=10,0,-0.1 do print(var) end
Are you sure this is a Lua error? Can you give a language/example where this works as you expected?
Unless using fixed/arbitrary precision, which have their own trade-offs, non-integer numbers in a computer tend to be stored in standard form in base 2. There will be a finite number of digits for both the mantissa and exponent (52 and 11 IIRC for normal Lua).
Try and write 1/10 in standard form in base 2, and you will see the problem.
Thanks,
Kev