数学包
该 math 包提供基本常量和数学函数。
导入 math 包:
import "math"
常量
math.e
math.ln10
math.ln2
math.log10e
math.log2e
math.maxfloat
math.maxint
math.maxuint
math.minint
math.phi
math.pi
math.smallestNonzeroFloat
math.sqrt2
math.sqrte
math.sqrtphi
math.sqrtpi
- math.e 表示自然对数的底数,也称为欧拉数。
- math.ln10 表示 10 的自然对数。
- math.ln2 表示2的自然对数。
- math.log10e 表示 e 的以10为底的对数 (
math.e). - math.log2e 表示 e 的以 2 为底的对数 (
math.e). - math.maxfloat 表示最大浮点值。
- math.maxint 表示最大整数值 (
2^63 - 1)。 - math.maxuint 代表最大无符号整数值 (
2^64 - 1). - math.minint 表示最小整数值 (
-2^63). - math.phi 表示 黄金比例。
- math.pi 代表圆周率 (π)。
- math.smallestNonzeroFloat 表示最小的非零浮点值。
- math.sqrt2 表示 2 的平方根。
- math.sqrte 代表 e 的平方根 (
math.e). - math.sqrtphi 表示黄金比例 (
math.phi) 的平方根。 - math.sqrtpi 表示圆周率 (π) 的平方根。
函数
- math.abs()
- math.acos()
- math.acosh()
- math.asin()
- math.asinh()
- math.atan()
- math.atan2()
- math.atanh()
- math.cbrt()
- math.ceil()
- math.copysign()
- math.cos()
- math.cosh()
- math.dim()
- math.erf()
- math.erfc()
- math.erfcinv()
- math.erfinv()
- math.exp()
- math.exp2()
- math.expm1()
- math.float64bits()
- math.float64frombits()
- math.floor()
- math.frexp()
- math.gamma()
- math.hypot()
- math.ilogb()
- math.isInf()
- math.isNaN()
- math.j0()
- math.j1()
- math.jn()
- math.ldexp()
- math.lgamma()
- math.log()
- math.log10()
- math.log1p()
- math.log2()
- math.logb()
- math.mInf()
- math.mMax()
- math.mMin()
- math.mod()
- math.modf()
- math.NaN()
- math.nextafter()
- math.pow()
- math.pow10()
- math.remainder()
- math.round()
- math.roundtoeven()
- math.signbit()
- math.sin()
- math.sincos()
- math.sinh()
- math.sqrt()
- math.tan()
- math.tanh()
- math.trunc()
- math.y0()
- math.y1()
- math.yn()