Presto 0.100 Documentation

5.5. 数学函数和运算符

5.5. 数学函数和运算符

数学运算符

运算符 描述
+ Addition
- Subtraction
* Multiplication
/ Division (integer division performs truncation)
% Modulus (remainder)

数学函数

abs(x) → [same as input]

返回x的绝对值

cbrt(x) → double

返回x的立方根

ceil(x) → [same as input]

ceiling()的同名方法

ceiling(x) → [same as input]

返回x的向上取整的数值

degrees(x) → double

Converts angle x in radians to degrees.

e() → double

Returns the constant Euler’s number.

exp(x) → double

Returns Euler’s number raised to the power of x.

floor(x) → [same as input]

Returns x rounded down to the nearest integer.

from_base(string, radix) → bigint

Returns the value of string interpreted as a base-radix number.

ln(x) → double

Returns the natural logarithm of x.

log2(x) → double

Returns the base 2 logarithm of x.

log10(x) → double

Returns the base 10 logarithm of x.

log(x, b) → double

Returns the base b logarithm of x.

mod(n, m) → [same as input]

Returns the modulus (remainder) of n divided by m.

pi() → double

Returns the constant Pi.

pow(x, p) → double

Returns x raised to the power of p.

radians(x) → double

Converts angle x in degrees to radians.

rand() → double

Alias for random().

random() → double

Returns a pseudo-random value in the range 0.0 <= x < 1.0

round(x) → [same as input]

Returns x rounded to the nearest integer.

round(x, d) → [same as input]

Returns x rounded to d decimal places.

sqrt(x) → double

Returns the square root of x.

to_base(x, radix) → varchar

Returns the base-radix representation of x.

三角函数

所有三角函数的参数都是以弧度表示。参考单位转换函数degrees()radians()

acos(x) → double

Returns the arc cosine of x.

asin(x) → double

Returns the arc sine of x.

atan(x) → double

Returns the arc tangent of x.

atan2(y, x) → double

Returns the arc tangent of y / x.

cos(x) → double

Returns the cosine of x.

cosh(x) → double

Returns the hyperbolic cosine of x.

sin(x) → double

Returns the sine of x.

tan(x) → double

Returns the tangent of x.

tanh(x) → double

Returns the hyperbolic tangent of x.

浮点函数

infinity() → double

返回代表正无穷大的常量Returns

is_finite(x) → boolean

Determine if x is finite.

is_infinite(x) → boolean

Determine if x is infinite.

is_nan(x) → boolean

Determine if x is not-a-number.

nan() → double

Returns the constant representing not-a-number.