Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python math.frexp() Method

Python math.frexp() Method

Python math Module Python math Module

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:

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

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 math Module