lua-users home
lua-l archive

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


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



On 23 March 2014 16:09, Andrew Starks <andrew.starks@trms.com> wrote:
This question comes from ignorance  and I'm sincerely curious:

My understanding is that 5.3 internally flips to 64 bit signed when it sees that it's out of integer space in the double. 

I presume that a similar strategy for positive ints that go beyond signed 64 bit would be too much to implement, or is it that it is presumed to not be needed enough to justify the complexity? Or maybe it would have other consequences?

I've seen overflow (surprise negative) results a few times, but it usually revealed a bug or was simple to get around. I'm genuinely curious, if someone has time to answer. 

Thanks!

-Andrew