lua-users home
lua-l archive

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


Op Di. 27 Nov. 2018 om 12:32 het pocomane <pocomane_7a@pocomane.com> geskryf:
>
> It seems to me that there is an inconsistency in how lua handles the
> min and the max integer literals. The following code ends without any
> error both in Lua 5.3 and Lua 5.4.
>
> ```
> -- Max integer, both literal and reference are ok
> assert(tostring(math.maxinteger) == '9223372036854775807')
> assert(tostring(9223372036854775807) == '9223372036854775807')
> assert(math.type(9223372036854775807) == 'integer')
>
> -- Min integer+1, literal is ok
> assert(tostring(-9223372036854775807) == '-9223372036854775807')
> assert(math.type(-9223372036854775807) == 'integer')
>
> -- Min integer, reference is ok
> assert(tostring(math.mininteger) == '-9223372036854775808')
> assert(math.type(math.mininteger) == 'integer')
>
> -- Min integer literal, BUG ???
> assert(tostring(-9223372036854775808) == '-9.2233720368548e+018')
> assert(math.type(-9223372036854775808) == 'float')
> ```
> Is it a bug?

On my system (Ubuntu 18.04, amd64 processor), the second-last
assertion fails, but the last one succeeds.