divide

Mathematical division

Definition

number divide(number $left, number $right)

Divides $left by $right.

Parameters

number $left

The number to be divided.

number$right

The number to divide by.

Returns

number

The quotient of $left and $right.

Examples

{
  a: divide('4', `2`),
  b: divide('5', `2`),
  c: divide(`4.0`, `true`),
  d: divide(`4.0`, `2.0`),
  e: divide(`4`, `0`),       // Error
  f: divide(`4`, `null`)     // Error
}
{
  "a": 2,
  "b": 2.5,
  "c": 4,
  "d": 2
}

Remarks

  • The returned number is always written as an integer if the result is an integer, even if both $left and $right are floats.
  • Division by zero returns an error.