Home >>Python math Module >Python math.frexp() Method

Python math.frexp() Method

Python math.frexp() Method

Python math.frexp() method in python is used to returns a tuple of mantissa and exponent of a given specified number, where mantissa as a float value and exponent as an integer value.

This method is calculated by this: number = mantissa x 2 x x exponent (or number = m x 2e)

Syntax:
math.frexp(x)

Parameter Values

Parameter Description
x It is required a number to return the value.
Here is an example of Python math.frexp() Method:

import math  
print(math.frexp(2.9))
print(math.frexp(5))

Output:
(0.725, 2)
(0.625, 3)
Example 2:

import math
v = 4
w = 9
x = -7
y = -9.065
z = 12.06
print("frexp(v): ", math.frexp(v))
print("frexp(w): ", math.frexp(w))
print("frexp(x): ", math.frexp(x))
print("frexp(y): ", math.frexp(y))
print("frexp(z): ", math.frexp(z))

Output:
frexp(v): (0.5, 3)
frexp(w): (0.5625, 4)
frexp(x): (-0.875, 3)
frexp(y): (-0.5665625, 4)
frexp(z): (0.75375, 4)

No Sidebar ads