Math

◷ Reading Time: 3 minutes

min

Returns the smallest of two numbers.

 min (value1, value2)

max

Returns the largest of two numbers.

 max (value1, value2)

floor

Returns the largest integer less than or equal to the specified number.

 floor (value)

round

Rounds a numeric value to the nearest integral or decimal value.

 round (value, decimals)
  • value: numeric value
  • decimals: numbers of required decimal to be round to
 Examples: round (23.4567 ,2)
 Result: 23.46 

ceiling

Returns the smallest integral value that is greater than or equal to the specified double-precision floating-point number.

 ceiling (value)

log

Returns the natural (or other base for) logarithm of a specified number.

 log (value, base)

value: the number to calculate log (Mandatory) base: base for the log (default is e)

abs

Returns the absolute value of a double-precision floating-point number.

 abs (value)

range

Generates and returns a sequence of integral numbers within a specified range.

 range (start, count)
  • start: the value of the first integer in the sequence
  • count: the number of sequential integers to generate
 Example: range (2,5)

 This generates 5 numbers starting from 2.

 Result: [2, 3, 4, 5, 6] 

rand

Generates and returns a random number within a specified range.

If you don’t specify any parameters, it will generate a decimal value between 0 and 1.

 rand (minimum, maximum, seed)
  • minimum: the value of the first integer in the sequence
  • maximum: the number of sequential integers to generate
  • seed: If you want to generate the same random number every time within the given minimum and maximum range
Example 1: rand(3,10)

 This generates a random number between 3 amd 10.

 Sample Result: 8  

Example 2: rand()

 This generates a random decimal value between 0 and 1.

 Sample Result: 0.444317978548034  
 
Example 3: rand(3,10,6)

 This generates the same random number between 3 amd 10 .

 Result: 9 

Example 4: rand(-20,-10)

 This generates a random number between -20 amd -10. 

 Result: -11  

Updated on September 7, 2020

Was this article helpful?

Related Articles