Skip to main content

frexp

Function frexp 

Source
pub fn frexp(x: number) -> (number, number)
Expand description

Splits a number into a normalized fraction and an exponent. Re-added in Lua 5.5 (it had been removed in 5.3).

§Parameters

  • x: a number.

§Return value

Two values m and e such that x == m * 2^e, where e is an integer and the absolute value of m is in the range [0.5, 1) — or zero when x is zero.

§Examples

print(math.frexp(8))      --> 0.5   4
print(math.frexp(1))      --> 0.5   1
print(math.frexp(0))      --> 0.0   0

§See also

ldexp