Table of Math Functions

NLP++ now features mathematical functions analogous to those provided in C/C++.

FUNCTION NAME

RETURNS

DESCRIPTION

abs(num)

NUM

Get the absolute value of a number.

ceiling(num_float)

NUM

Round a number up to the nearest whole number. Analogous to the ceil function in C/C++.

factorial(num)

NUM

Get the factorial of a whole number.

floor(num_float)

NUM

Round a number down to the nearest whole number. Analogous to the floor function in C/C++.

log(num_float)

FLOAT

Get the natural (base e) logarithm of a number. Analogous to the log function in C/C++.

logten(num_float)

FLOAT

Get the base 10 logarithm of a number. Analogous to the log10 function in C/C++.

mod(num,num)

NUM

Get the remainder after dividing the first number by the second. Analogous to the % operator in C/C++.

pow(base_float,exponent_float)

FLOAT

Raise a number to the given power. Analogous to the pow function in C/C++.

randomint(num,num)

NUM

Get a random whole number between the two given numbers, inclusive.

round(num_float)

NUM

Round a number to the nearest whole number, with halfway cases rounding away from zero. Analogous to the round function in C/C++.

sqrt(num_float)

FLOAT

Get the square root of a number. Analogous to the sqrt function in C/C++.

truncate(num_float)

NUM

Discard the fractional part of a number, rounding toward zero. Analogous to the trunc function in C/C++.

See Also