属性和描述 |
E
欧拉常数和自然对数的底,大约为 2.718、
|
LN2
2 的自然对数,约为 0.693、
|
LN10
10 的自然对数,大约为 2.302、
|
LOG2E
E 的以 2 为底的对数,大约为 1.442、
|
LOG10E
E 的以 10 为底的对数,大约为 0.434、
|
PI
圆的周长与其直径的比值,约为 3.14159、
|
SQRT1_2
1/2 的平方根;等效地,1 超过 2 的平方根,大约为 0.707、
|
SQRT2
2 的平方根,大约为 1.414、
|
e_value = Math.E console.log "The value of the constant E is: " + e_value LN2_value = Math.LN2 console.log "The value of the constant LN2 is: " + LN2_value LN10_value = Math.LN10 console.log "The value of the constant LN10 is: " + LN10_value LOG2E_value = Math.LOG2E console.log "The value of the constant LOG2E is: " + LOG2E_value LOG10E_value = Math.LOG10E console.log "The value of the constant LOG10E is: " + LOG10E_value PI_value = Math.PI console.log "The value of the constant PI is: " + PI_value SQRT1_2_value = Math.SQRT1_2 console.log "The value of the constant SQRT1_2 is: " + SQRT1_2_value SQRT2_value = Math.SQRT2 console.log "The value of the constant SQRT2 is: " + SQRT2_value
c:\> coffee-c math_example.coffee
// Generated by CoffeeScript 1.10.0 (function() { var LN10_value, LN2_value, LOG10E_value, LOG2E_value, PI_value, SQRT1_2_value, SQRT2_value, e_value; e_value = Math.E; console.log("The value of the constant E is: " + e_value); LN2_value = Math.LN2; console.log("The value of the constant LN2 is: " + LN2_value); LN10_value = Math.LN10; console.log("The value of the constant LN10 is: " + LN10_value); LOG2E_value = Math.LOG2E; console.log("The value of the constant LOG2E is: " + LOG2E_value); LOG10E_value = Math.LOG10E; console.log("The value of the constant LOG10E is: " + LOG10E_value); PI_value = Math.PI; console.log("The value of the constant PI is: " + PI_value); SQRT1_2_value = Math.SQRT1_2; console.log("The value of the constant SQRT1_2 is: " + SQRT1_2_value); SQRT2_value = Math.SQRT2; console.log("The value of the constant SQRT2 is: " + SQRT2_value); }).call(this);
c:\> coffee math_example.coffee
The value of the constant E is: 2.718281828459045 The value of the constant LN2 is: 0.6931471805599453 The value of the constant LN10 is: 2.302585092994046 The value of the constant LOG2E is: 1.4426950408889634 The value of the constant LOG10E is: 0.4342944819032518 The value of the constant PI is: 3.141592653589793 The value of the constant SQRT1_2 is: 0.7071067811865476 The value of the constant SQRT2 is: 1.4142135623730951
方法和说明 |
abs()
返回数字的绝对值。
|
acos()
返回数字的反余弦值(以弧度为单位)。
|
asin()
返回一个数字的反正弦(以弧度为单位)。
|
atan()
返回一个数字的反正切(以弧度为单位)。
|
atan2()
返回其参数商的反正切。
|
ceil()
返回大于或等于数字的最小整数。
|
cos()
返回数字的余弦。
|
exp()
返回 E
N,其中 N 是参数,E 是欧拉常数,自然对数的底数。
|
floor()
返回小于或等于数字的最大整数。
|
log()
返回数字的自然对数(以 E 为底)。
|
max()
返回零个或多个数字中的最大值。
|
min()
返回零个或多个数字中最小的一个。
|
pow()
返回基数的指数幂,即基数指数。
|
random()
返回一个介于 0 和 1 之间的伪随机数。
|
round()
返回四舍五入到最接近整数的数字的值。
|
sin()
返回数字的正弦值。
|
sqrt()
返回数字的平方根。
|
tan()
返回数字的正切。
|