subtract

Mathematical subtraction of two arguments

Definition

number subtract(number $left, number $right)

Returns $left - $right.

Parameters

number $left

The left argument of subtraction, number to subtract from.

number $right

The right argument of subtraction, number to subtract.

Returns

number

The difference of the two parameters.

Examples

{
  diff: subtract(`3`, `2`),
  diff2: subtract(`3`, `-2`),
  float_string_diff: subtract('3.1', '2.1'),
  float_diff: subtract(`3.1`, `2.8`),
  bool_diff: subtract(`true`, `10`),
  null_diff: subtract(`null`, `null`),        // Error
  text_diff: subtract('a', 'b'),              // Error
  array_diff: subtract(`[5]`, `[1]`),         // Error
  object_diff: subtract(`{a: 1}`, `{a: 0}`)   // Error
}
{
  "diff": 1,
  "diff2": 5,
  "float_string_diff": 1,
  "float_diff": 0.3,
  "bool_diff": -9
}

Remarks

boolean arguments are valid as well and implicitly converted to their integer values. Same holds for string arguments that follow a number format. However, it is recommended to call the function with number parameters.