Although tydok's reference to PiL 2.3 is both correct and apropos, and Javier's answer is in practice correct, I thought the discussion of numbers in Lua should be rounded out with a couple of other details.
The Lua interpreter is designed to be embedded in an application typically as a configuration and/or scripting language. When built for an application, it is common to configure some of its features to suit.
The exact numeric type to use for numbers is available for configuration. When compiling for a platform without hardware floating point where loading third-party modules is not important (especially in an embedded system or set-top box game console application) then it is reasonable to pick an integral type instead of the default double
. Occasionally, switching to float
is reasonable also.
However, there are applications where 64-bit integers are needed, or most numbers can be integers but occasional floating point arithmetic is required. For those cases, there is the LNUM patch to the Lua core.
LNUM changes the core so that numbers are stored as either integers or floating point, and allows several configurable selections for the precision of each.
So the bottom line answer to the question of the maximum value of a Lua number is that it depends on the configuration of the interpreter chosen at compile time, and whether you are worried about the maximum magnitude representable or the maximum integer. And even then, work has been done to make large integers play well with floating point representations.