Python math.frexp() Method
Python math.frexp(x) The method returns the mantissa and exponent of x as an (m, e) pair.
The mathematical formula for this method is: number = m * 2**e.
Python version: 2.6
Syntax
The syntax of the math.frexp() method is as follows:
math.frexp(x)
Parameter Description:
- x -- required, a positive or negative number. If x is not a number, a TypeError is returned.
Return Value
A tuple returning the mantissa and exponent of x as an (m, e) pair.
Example
The following example computes the mantissa and exponent of a number:
Example
Import the math package
import
math
Return the mantissa and exponent of the number
(
math
.
frexp
(
4
)
)
(
math
.
frexp
(
4
)
)
(
math
.
frexp
(
7
)
)
Output result:
(0.5, 3)
(-0.5, 3)
(0.875, 3)
Python math Module