What is the maximum value of a number in Lua?

前端 未结 5 1768
执笔经年
执笔经年 2020-12-14 02:11

There doesn\'t seem to be a clear answer to this in the documentation.

I\'m interested in incrementing a variable time that counts the seconds since the

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-14 02:36

    I found this email on the lua users site

    The Lua core does not make use of 64 bit datatypes, except implicitly through size_t or ptrdiff_t (which happen to be 64 bit on a 64 bit box).

    sizeof( float ) == 4
    sizeof( double) == 8

    You can define lua_Number to be a double (default), float or any integer with at least 32 bits. There are side effects though and some extensions may cease to work due to the limited range of floats or ints. The core should be fine, though.

提交回复
热议问题