subtract

Modified on Thu, 9 Jul at 10:49 AM

subtract

TABLE OF CONTENTS

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

Transformation
{
  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
}
Result
{
  "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.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article