math.frexp

Break number into mantissa and exponent

Prototype

m, n = math.frexp (v)

Description

The frexp function breaks down the floating-point value (v) into a mantissa (m) and an exponent (n), such that the absolute value of m is greater than or equal to 0.5 and less than 1.0, and v = m * 2^n.

Note that math.ldexp is the inverse operation.

m, n = math.frexp (1.23456e24)
print (m) --> 0.51060204851673
print (n) --> 81
print ( 0.51060204851673 * 2^81 )  --> 1.23456e+024

Lua functions

Topics