Python Tutorial Python Advanced Python References Python Libraries

Python math - frexp() Function



The Python math.frexp() function returns the mantissa and exponent of the argument as the pair (mantissa, exponent). mantissa is a float number and exponent is an integer number such that:

x = mantissa * 2exponent

If x is zero, the method returns (0.0, 0), otherwise 0.5 <= abs(mantissa) < 1.

Syntax

math.frexp(x)

Parameters

x Required. Specify a number.

Return Value

Returns the mantissa and exponent of the argument.

Example:

In the example below, frexp() function returns the mantissa and exponent of the given number.

import math

print(math.frexp(10))
print(math.frexp(1000))
print(math.frexp(5000))

The output of the above code will be:

(0.625, 4)
(0.9765625, 10)
(0.6103515625, 13)

❮ Python Math Module