Math.frexp: Difference between revisions

From GiderosMobile
No edit summary
No edit summary
Line 4: Line 4:


=== Description ===
=== Description ===
Returns m and e such that v = m2^e, e is an integer and the absolute value of m is in the range [0.5, 1) (or zero when v is zero).
Used to split a floating-point number (v) into a normalized fraction (a mantissa) and an integer exponent.
<source lang="lua">
<source lang="lua">
(number) = math.frexp(v)
(number) (number) = math.frexp(v)
</source>
</source>
Returns m and e such that v = m*2^e, e is an integer and the absolute value of m is in the range [0.5, 1) (or zero when v is zero).


=== Parameters ===
=== Parameters ===
Line 13: Line 15:


=== Return values ===
=== Return values ===
'''Returns''' (number) result<br/>
'''Returns''' (number) the mantissa, a multiplier in the range [0.5, 1) (normalized fraction)<br/>
'''Returns''' (number) the exponent as an integer<br/>
 
=== Note ===
[[math.ldexp]] is the inverse operation.


{{Math}}
{{Math}}

Revision as of 08:05, 14 November 2022

Available since: Gideros 2011.6
Class: math

Description

Used to split a floating-point number (v) into a normalized fraction (a mantissa) and an integer exponent.

(number) (number) = math.frexp(v)

Returns m and e such that v = m*2^e, e is an integer and the absolute value of m is in the range [0.5, 1) (or zero when v is zero).

Parameters

v: (number) value

Return values

Returns (number) the mantissa, a multiplier in the range [0.5, 1) (normalized fraction)
Returns (number) the exponent as an integer

Note

math.ldexp is the inverse operation.