Math Functions
Mathematical functions and constants available in kScript v2.0 through the math namespace.
Usage
All math functions are accessed through the math
namespace and use keyword arguments:
Mathematical Constants
math.E
Euler's number, the base of natural logarithms
math.PI
The ratio of a circle's circumference to its diameter
math.SQRT2
The square root of 2
math.SQRT1_2
The square root of 1/2
math.LN2
The natural logarithm of 2
math.LN10
The natural logarithm of 10
math.LOG2E
The base-2 logarithm of E
math.LOG10E
The base-10 logarithm of E
Available Functions
math.abs()
Returns the absolute value of a number
math.abs(value)
math.ceil()
Returns the smallest integer greater than or equal to the given number
math.ceil(value)
math.floor()
Returns the largest integer less than or equal to the given number
math.floor(value)
math.round()
Returns the value rounded to the nearest integer
math.round(value)
math.trunc()
Returns the integer part of a number by removing fractional digits
math.trunc(value)
math.sign()
Returns the sign of a number: 1, -1, or 0
math.sign(value)
math.max()
Returns the largest of the given numbers
math.max(a, b, ...)
math.min()
Returns the smallest of the given numbers
math.min(a, b, ...)
math.random()
Returns a random number between 0 and 1
math.random()
math.sin()
Returns the sine of a number (in radians)
math.sin(value)
math.cos()
Returns the cosine of a number (in radians)
math.cos(value)
math.tan()
Returns the tangent of a number (in radians)
math.tan(value)
math.asin()
Returns the arcsine of a number, in radians
math.asin(value)
math.acos()
Returns the arccosine of a number, in radians
math.acos(value)
math.atan()
Returns the arctangent of a number, in radians
math.atan(value)
math.atan2()
Returns the arctangent of y/x, in radians
math.atan2(y, x)
math.sinh()
Returns the hyperbolic sine of a number
math.sinh(value)
math.cosh()
Returns the hyperbolic cosine of a number
math.cosh(value)
math.tanh()
Returns the hyperbolic tangent of a number
math.tanh(value)
math.asinh()
Returns the inverse hyperbolic sine of a number
math.asinh(value)
math.acosh()
Returns the inverse hyperbolic cosine of a number
math.acosh(value)
math.atanh()
Returns the inverse hyperbolic tangent of a number
math.atanh(value)
math.exp()
Returns e raised to the power of the given number
math.exp(value)
math.expm1()
Returns e^x - 1
math.expm1(value)
math.log()
Returns the natural logarithm of a number
math.log(value)
math.log1p()
Returns the natural logarithm of 1 + x
math.log1p(value)
math.log2()
Returns the base-2 logarithm of a number
math.log2(value)
math.log10()
Returns the base-10 logarithm of a number
math.log10(value)
math.pow()
Returns base raised to the power of exponent
math.pow(base, exponent)
math.sqrt()
Returns the square root of a number
math.sqrt(value)
math.cbrt()
Returns the cube root of a number
math.cbrt(value)
math.hypot()
Returns the square root of the sum of squares of arguments
math.hypot(a, b, ...)