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) are omitted; we target Lua 5.4 semantics only. See PORTING.md §13.

Functions§

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