Skip to main content

Module math_lib

Module math_lib 

Source
Expand description

Standard mathematical library — math.*

Translated from src/lmathlib.c (Lua 5.4.7, 782 lines, 28 functions).

The PRNG is xoshiro256** operating on four 64-bit words. In C the implementation has two code paths (64-bit integers vs two 32-bit halves); Rust always has u64, so only the 64-bit path is kept.

Deprecated compat functions guarded by LUA_COMPAT_MATHLIB (cosh, sinh, tanh, pow, frexp, ldexp, log10, atan2) ship in the default lua5.3.6 build and are registered only under the 5.3 backend (luaopen_math gates them on LuaVersion::V53); they remain absent in 5.4/5.5. atan2 is an alias of the existing math_atan. See specs/followup/5.3-math.md.

Functions§

luaopen_math
Open the math library: create the table, populate constants, register the PRNG functions with their shared RanState upvalue.