Python math.frexp() Method
Example
Find the mantissa and exponent of a number:
#Import math Library
import math
#Return mantissa and exponent
of a given number
print(math.frexp(4))
print(math.frexp(7.9))
Try it Yourself »
Definition and Usage
The math.frexp()
method returns the mantissa
and the exponent, of a specified value, as a pair (m,e). The
mantissa (m) as a float, and the exponent (e) as an integer.
The calculation for this method is: number = mantissa x 2 x x exponent (or number = m x 2e)
Syntax
math.frexp(x)
Parameter Values
Parameter | Description |
---|---|
x | Required. A number. If the value is not a number, it returns TypeError |
Technical Details
Return Value: | A tuple value, the mantissa and exponent as a pair (m,e), First value is in float and the second value is an integer |
---|---|
Python Version: | 2.6 |