math – 数学函数¶
This module implements a subset of the corresponding CPython module,
as described below. For more information, refer to the original
CPython documentation: math。
math 模块提供了一些基本的数学函数,用于处理浮点数。
注意: 在 pyboard 上,浮点数精度为 32 位。
函数¶
- math.acos(x)¶
返回
x的反余弦值。
- math.acosh(x)¶
返回
x的反双曲余弦值。
- math.asin(x)¶
返回
x的反正弦值。
- math.asinh(x)¶
返回
x的反双曲正弦值。
- math.atan(x)¶
返回
x的反正切值。
- math.atan2(y, x)¶
返回
y/x的反正切主值。
- math.atanh(x)¶
返回
x的反双曲正切值。
- math.ceil(x)¶
返回一个整数,将
x四舍五入到正无穷大。
- math.copysign(x, y)¶
返回带有
y符号的x。
- math.cos(x)¶
返回
x的余弦值。
- math.cosh(x)¶
返回
x的双曲余弦值。
- math.degrees(x)¶
返回弧度
x转换为度数。
- math.erf(x)¶
返回
x的误差函数。
- math.erfc(x)¶
返回
x的互补误差函数。
- math.exp(x)¶
返回
x的指数函数。
- math.expm1(x)¶
返回
exp(x) - 1。
- math.fabs(x)¶
返回
x的绝对值。
- math.floor(x)¶
返回一个整数,将
x四舍五入到负无穷大。
- math.fmod(x, y)¶
返回
x/y的余数。
- math.frexp(x)¶
将浮点数分解为尾数和指数。返回值是元组
(m, e),使得x == m * 2**e。如果x == 0,则函数返回(0.0, 0),否则满足关系式0.5 <= abs(m) < 1。
- math.gamma(x)¶
返回
x的伽玛函数。
- math.isfinite(x)¶
如果
x是有限数,则返回True。
- math.isinf(x)¶
如果
x是无穷大数,则返回True。
- math.isnan(x)¶
如果
x是非数字,则返回True
- math.ldexp(x, exp)¶
返回
x * (2**exp)。
- math.lgamma(x)¶
返回
x的伽玛函数的自然对数。
- math.log(x)¶
返回
x的自然对数。
- math.log10(x)¶
返回
x的以 10 为底的对数。
- math.log2(x)¶
返回
x的以 2 为底的对数。
- math.modf(x)¶
返回一个包含两个浮点数的元组,分别是
x的小数部分和整数部分。两个返回值的符号与x相同。
- math.pow(x, y)¶
返回
x的y次幂。
- math.radians(x)¶
返回度数
x转换为弧度。
- math.sin(x)¶
返回
x的正弦值。
- math.sinh(x)¶
返回
x的双曲正弦值。
- math.sqrt(x)¶
返回
x的平方根。
- math.tan(x)¶
返回
x的正切值。
- math.tanh(x)¶
返回
x的双曲正切值。
- math.trunc(x)¶
返回一个整数,将
x四舍五入到 0。
常量¶
- math.e¶
自然对数的底数
- math.pi¶
圆周长与直径之比