> We thank everyone for their feedback on Lua 5.5.0 till now.
> If there is no further feedback, we'll freeze it next week,
> and it will become the current version of Lua.
Suggestion: add machine limits for the Lua number
Description: in scientific algorithms (e.g.: least squares of a mathematical function), it is often required to know the available characteristics of floating types like the maximum representable finite floating-point number, the epsilon, the radix, and so on.
In Python (NumPy library), most of these are defined at
https://numpy.org/doc/2.4/reference/generated/numpy.finfo.htmlIn Fortran -- I don't have any experience in Fortran -- these functions seems to be grouped into inquiry intrinsic functions:
https://fortranwiki.org/fortran/show/Intrinsic+typeshttps://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2023-0/inquiry-intrinsic-functions.htmlhttps://www.ibm.com/docs/en/openxl-fortran-aix/17.1.4?topic=procedures-inquiry-intrinsic-functionsSince Lua is grounded on C89, and as I can see on section "2.2.4.2.2 Characteristics of Floating Types <float.h>", these constants could be easily added to Lua.
Example using the Lua C API would look like:
lua_Number math_epsilon = l_floatatt(EPSILON);
lua_Number math_tiny = l_floatatt(MIN);
lua_Number math_max = l_floatatt(MAX);
In short, my suggestion is that such constants should be made available -- in the Lua side, in the math library -- in the same spirit as math.pi currently is.