Easy Tutorial
❮ Python Cube Sum Python Date Time ❯

Python math.frexp() Method

Python math Module

The math.frexp(x) method in Python returns the mantissa and exponent of x as the pair (m, e).

The mathematical formula for this method is: number = m * 2**e.

Python Version: 2.6

Syntax

The syntax for the math.frexp() method is as follows:

math.frexp(x)

Parameter:

Return Value

A tuple, returning the mantissa and exponent of x as the pair (m, e).

Example

The following example calculates the mantissa and exponent of a number:

Example

# Import math package
import math

# Return the mantissa and exponent of the number
print(math.frexp(4))
print(math.frexp(-4))
print(math.frexp(7))

Output result:

(0.5, 3)
(-0.5, 3)
(0.875, 3)

Python math Module

❮ Python Cube Sum Python Date Time ❯