Return to index

math functions

positive_number = abs(number)

top

Calculate absolute value of number.

Example:

# Example for abs
println abs(-5)  # 5


float = acos(number)

top

Calculate arc cosine of number.

Example:

# Example for acos
println acos(1)  # 0


float = acosh(number)

top

Calculate hyberbolic arc cosine of number.

Example:

# Example for acosh
println acosh(2)  # ~1.316


float = asin(number)

top

Calculate arc sine of number.

Example:

# Example for asin
println asin(0.5)  # 0.5235...


float = asinh(number)

top

Calculate hyberbolic arc sine of number.

Example:

# Example for asinh
println asinh(1)  # ~0.881


float = atan(number)

top

Calculate arc tangent of number.

Example:

# Example for atan
println atan(1)  # 0.785398...


float = atanh(number)

top

Calculate hyberbolic arc tangent of number.

Example:

# Example for atanh
println atanh(0.5)  # 0.5493...


float = cos(number)

top

Calculate cosine of number.

Example:

# Example for cos
println cos(0.5)  # ~0.877


float = cosh(number)

top

Calculate hyberbolic cosine of number.

Example:

# Example for cosh
println cosh(1)  # ~1.543


float = deg2rad(number)

top

Convert degrees to radians.

Example:

# Example for deg2rad
println deg2rad(180)  # 3.14159...


float = e()

top

Returns the value of e.

Example:

# Example for e
println e()  # 2.7182...


float = floor(float)

top

Round float down to nearest integer.

Example:

# Example for floor
println floor(1.9)  # 1


string = ibase(n,int)

top

Returns a string holding a conversion of int to base n

Example:

# Example for ibase
println ibase(2,10)  # "1010"


float = ln(number)

top

Calculate natural logarithm of number.

Example:

# Example for ln
println ln(2.71828)  # ~1


float = ln10()

top

Returns the value of ln10.

Example:

# Example for ln10
println ln10()  # 2.302585


float = ln2()

top

Returns the value of ln2.

Example:

# Example for ln2
println ln2()  # ~0.693


float = log10(number)

top

Calculate logarithm (base 10) of number.

Example:

# Example for log10
println log10(100)  # 2


float = log2(number)

top

Calculate logarithm (base 2) of number.

Example:

# Example for log2
println log2(8)  # 3


float = logn(number,base)

top

Calculate logarithm (base base) of number. FP results may be fuzzy. logn(0,x) is reported as 0f.

Example:

# Example for logn
println logn(8,2)  # 3


string = numcomma(number[,precision])

top

Returns formatted number. This does not work with big ints or floats.

Example:

# Example for numcomma
println numcomma(1000000)  # 1,000,000


float = phi()

top

Returns the value of phi.

Example:

# Example for phi
println phi()  # 1.618033...


float = pi()

top

Returns the value of pi.

Example:

# Example for pi
println pi()  # 3.141592653589793


float = pow(number,n)

top

Calculate number raised to the power n.

Example:

# Example for pow
println pow(2,3)  # 8


bigfloat = prec(bigfloat,prec)

top

Returns a big float with a set precision (prec bits).


float = rad2deg(number)

top

Convert radians to degrees.

Example:

# Example for rad2deg
println rad2deg(3.14159)  # 180


int = rand(positive_max_int)

top

Generate a random integer between 1 and positive_max_int inclusive.

Example:

# Example for rand
println rand(100)  # e.g., 73


float = randf()

top

Generate a random float between 0 and 1.

Example:

# Example for randf
println randf()


float = round(float)

top

Round float to nearest integer.

Example:

# Example for round
println round(1.7)  # 2


seed(number)

top

Set the random seed. number of -1 sets the seed using current nano-second time.

Example:

# Example for seed
seed(1234)


float = sin(number)

top

Calculate sine of number.

Example:

# Example for sin
println sin(3.14/2)  # ~1


float = sinh(number)

top

Calculate hyberbolic sine of number.

Example:

# Example for sinh
println sinh(0.5)  # ~0.521


float = tan(number)

top

Calculate tangent of number.

Example:

# Example for tan
println tan(0.5)


float = tanh(number)

top

Calculate hyberbolic tangent of number.

Example:

# Example for tanh
println tanh(1)  # 0.7615...


int = ubin8(unsigned_binary_string)

top

unsigned binary to decimal. (8-bit)


int = uhex32(unsigned_hex_string)

top

unsigned hexadecimal to decimal. (16-bit)