This page outlines arithmetic/math functions in NetScript.
Basic Operations
This section lists the basic math operations you can perform using NetScript.
number + number
This function returns the sum of the inputs.
Function: number + number
Data Type: number
Example:
5 + 7
12
number - number
This function returns the difference of the inputs.
Function: number - number
Data Type: number
Example:
13-10
3
number * number
This function returns the product of the inputs.
Function: number * number
Data Type: number
Example:
7 * 8
56
number / number
This function returns the division of the inputs.
Function: number / number
Data Type: number
Example:
84 / 4
21
number ^ number
This function returns number1 raised to the power of number2 .
Function: number ^ number
Data Type: number
Example:
2 ^ 9
512
Advanced Operations
This table lists the advanced operations you can invoke using NetScript:
floor(number)
This function rounds the number down to the nearest integer.
Function: floor(number)
Data Type: number
Example:
floor(17.36)
17
round(number[, N])
This function rounds the number to the given precision (N), which is 0 by default. Precision value can be positive or negative and indicates the number of decimal places displayed in the rounded number.
Function: round(number[, <N>])
Data Type: number
Example:
round(23.45)
round(23.45, 0)
round(23.45, 1)
round(23.45, -1)
truncate(number[, N])
This function rounds the number down to the given precision (N), which is 0 by default.
Function: truncate(number[, <N>])
Data Type: number
Example:
truncate(23.45)
truncate(23.45, 0)
truncate(23.45, 1)
truncate(23.45, -1)
sqrt(number)
This function returns the square root (full-precision decimal) of the input.
Function: sqrt(number)
Data Type: number
Example:
sqrt(64)
8
least(number(, number)*)
This function returns whichever number has the smallest value.
Function: least(number(, number)*)
Data Type: number
Example:
least(7(, 23)*)
7
greatest(number(, number)*)
This function returns whichever number has the largest value.
Function: greatest(number(, number)*)
Data Type: number
Example:
greatest(7(, 23)*)
23
Please sign in to leave a comment.