[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: 5.3 unsigned fall-over?
- From: Andrew Starks <andrew.starks@...>
- Date: Sun, 23 Mar 2014 21:20:13 -0500
On Sunday, March 23, 2014, Raphael Lydia Bertoche <rbertoche@cpti.cetuc.puc-rio.br> wrote:
This wont apply for double. Now Integers won't become double anymore, loosing precision. They may only overflow.
Lua 5.3.0 (work2) Copyright (C) 1994-2014 Lua.org, PUC-Rio
> 1000*1000*1000*1000*1000*1000
1000000000000000000
> 1000*1000*1000*1000*1000*1000*10
-8446744073709551616
> 1000*1000*1000*1000*1000*1000*100
7766279631452241920
> 1000*1000*1000*1000*1000*1000*100.0
1e+20
Lua 5.2.3 Copyright (C) 1994-2013 Lua.org, PUC-Rio
> =1000*1000*1000*1000*1000*1000
1e+18
> =1000*1000*1000*1000*1000
1e+15
> =1000*1000*1000*1000
1000000000000
That makes sense. As an interim value, the overflow helps, for one round. Then, of course, it doesn't and flipping back to float is best.
I take it that trapping overflow unsigned int and going to float is more difficult than it's worth?