Math & Text
sub
$sub[]
The function $sub[] subtracts every following value from the first one, from left to right. It needs at least 1 argument and has no upper limit.
Syntax
$sub[value1;(value2;...)]
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
value1 |
number | Yes | The starting value (minuend). |
value2;(value3;...) |
number | No | The values to subtract, in order. |
Behavior
- Returns
value1 - value2 - value3 ....$sub[10;3;2]→5. - The result can be negative.
- Integers are subtracted exactly (arbitrary size). If a decimal number is involved, the subtraction is done on decimals.
- A value that is not a finite number (text, empty) raises the error “Expected a finite number in argument N.”.
- With a single number the result is that number (rounded to an integer unless
$enableDecimals[yes]):$sub[5]→5,$sub[2.5]→3. The number is still checked and at least one is required ($sub[]raises “Expected a finite number in argument 1.”). - Unless decimals are enabled with
$enableDecimals, a non-integer result is rounded to the nearest integer ($sub[10.5;3.2]→7).
Examples
Subtraction Calculation
$title[Math: Subtraction]
$description[Result of `10 - 3`: **$sub[10;3]**]
$addField[Negative Difference;$sub[5;10];yes]
$addField[Decimal Difference;$sub[10.5;3.2];yes]
$color[#5865F2]
Notes
- Use
$enableDecimals[yes]to keep decimal results ($sub[10.5;3.2]→7.3). - For more complex operations, use
$calculate[]. - The separator is the semicolon
;.
Try it
Paste an example into the playground to preview its message (functions that act on Discord are not run), or build the same thing with blocks.