Math Functions

Operators

JSLogo supports the standard math operators: +, -, /, *, % (modulus).

print 4 + 5
>9

Comparisons

JSLogo can compare values using =, <, >, <= and >=, returning true or false depending on the resolution.

Math Functions

NameArgumentsDescription
remaindernumerator denominator (two numbers)Returns the remainder following the division operation
roundnumberReturns rounded integer; alias int
intnumberReturns the integer part of a decimal number. Alias floor.
ceilnumberReturns the nearest integer greater or equal to the number.
minusnumberReturns the provided number with the opposite sign
sinnumberReturns sin(number)
cosnumberReturns cos(number)
tannumberReturns tan(number)
sqrtnumberReturns the square root of the number
sumnumber numberReturns sum of the two arguments
differencenumber numberReturns the difference of the two arguments
quotiantnumerator denominatorReturns the quotiant of the two argument
lnnumberReturns the natural log of the argument, ln(number)
powernumber numberReturns the first argument raised to the power of the second argument
randomnumber or array of two numbersReturns a random number from 0 to the argument or, when providing an array, between the first two members of the array
absnumberReturns the absolute value of the argument
Last updated on December 21, 2022