frexp 中文
Python math.frexp()方法 (Python math.frexp() method)
math.frexp() method is a library method of math module, it is used to get the pair of mantissa and exponent of the given number, it accepts a number (integer or float) and returns a tuple of mantissa and exponent of the given number, where mantissa is a float value and exponent is an integer value.
math.frexp()方法是数学模块的库方法,用于获取给定数字的尾数和指数对,它接受一个数字(整数或浮点数)并返回给定的尾数和指数的元组数字,其中尾数是浮点值,指数是整数值。
Where, the combination of mantissa and exponent should is like, number = mantissa*2**exponent.
其中,尾数和指数的组合应为: number =尾数* 2 ** exponent 。
Note: If anything is passed except the number, the method returns a type error, "TypeError: a float is required".
注意:如果传递了除数字以外的任何内容,则该方法将返回类型错误“ TypeError:需要浮点数”。
Syntax of math.frexp() method:
math.frexp()方法的语法:
math.frexp(n)
Parameter(s): a – a number (float/integer).
参数: a –一个数字(浮点数/整数)。
Return value: tuple – it returns a tuple containing the mantissa and exponent part of the given number n.
返回值: tuple –返回一个包含给定数字n的尾数和指数部分的元组。
Example:
例:
Input:
a = 10
# function call
print(math.frexp(a))
Output:
(0.625, 4)
Python代码演示math.frexp()方法的示例 (Python code to demonstrate example of math.frexp() method)
# Python code demonstrate example of
# math.frexp() method
import math
# numbers
a = 0
b = 10
c = -10
d = 10.234
e = -10.234
# printing the mantissa and exponent
print("frexp(a): ", math.frexp(a))
print("frexp(b): ", math.frexp(b))
print("frexp(c): ", math.frexp(c))
print("frexp(d): ", math.frexp(d))
print("frexp(e): ", math.frexp(e))
Output
输出量
frexp(a): (0.0, 0)
frexp(b): (0.625, 4)
frexp(c): (-0.625, 4)
frexp(d): (0.639625, 4)
frexp(e): (-0.639625, 4)
翻译自: https://www.includehelp.com/python/math-frexp-method-with-example.aspx
frexp 中文