...

Text file src/github.com/go-task/slim-sprig/v3/docs/math.md

Documentation: github.com/go-task/slim-sprig/v3/docs

     1# Integer Math Functions
     2
     3The following math functions operate on `int64` values.
     4
     5## add
     6
     7Sum numbers with `add`. Accepts two or more inputs.
     8
     9```
    10add 1 2 3
    11```
    12
    13## add1
    14
    15To increment by 1, use `add1`
    16
    17## sub
    18
    19To subtract, use `sub`
    20
    21## div
    22
    23Perform integer division with `div`
    24
    25## mod
    26
    27Modulo with `mod`
    28
    29## mul
    30
    31Multiply with `mul`. Accepts two or more inputs.
    32
    33```
    34mul 1 2 3
    35```
    36
    37## max
    38
    39Return the largest of a series of integers:
    40
    41This will return `3`:
    42
    43```
    44max 1 2 3
    45```
    46
    47## min
    48
    49Return the smallest of a series of integers.
    50
    51`min 1 2 3` will return `1`
    52
    53## floor
    54
    55Returns the greatest float value less than or equal to input value
    56
    57`floor 123.9999` will return `123.0`
    58
    59## ceil
    60
    61Returns the greatest float value greater than or equal to input value
    62
    63`ceil 123.001` will return `124.0`
    64
    65## round
    66
    67Returns a float value with the remainder rounded to the given number to digits after the decimal point.
    68
    69`round 123.555555 3` will return `123.556`
    70
    71## randInt
    72Returns a random integer value from min (inclusive) to max (exclusive).
    73
    74```
    75randInt 12 30
    76```
    77
    78The above will produce a random number in the range [12,30].

View as plain text