Math
num_abs¶
Absolute value of an integer.
Example¶
num_abs -5 # => 5
num_abs 3 # => 3
Arguments¶
- $1 (int): Integer (may be negative)
Exit codes¶
- 0: Always; 1 Missing or non-integer argument
Output on stdout¶
- Absolute value
num_min¶
Return the lesser of two integers.
Example¶
num_min 3 7 # => 3
num_min -2 1 # => -2
Arguments¶
- $1 (int): First integer
- $2 (int): Second integer
Exit codes¶
- 0: Always; 1 Missing argument
Output on stdout¶
- Smaller value
num_max¶
Return the greater of two integers.
Example¶
num_max 3 7 # => 7
num_max -2 1 # => 1
Arguments¶
- $1 (int): First integer
- $2 (int): Second integer
Exit codes¶
- 0: Always; 1 Missing argument
Output on stdout¶
- Larger value
num_modulo¶
Integer modulo: a mod m. Result has the same sign as the divisor (mathematical modulo).
Example¶
num_modulo 10 3 # => 1
num_modulo -7 3 # => 2 (mathematical, not C-style)
Arguments¶
- $1 (int): Dividend
- $2 (int): Divisor (must be non-zero)
Exit codes¶
- 0: Always; 1 Division by zero or missing argument
Output on stdout¶
- Modulo result
num_clamp¶
Clamp an integer to [min, max].
Example¶
num_clamp 15 0 10 # => 10
num_clamp -3 0 10 # => 0
num_clamp 5 0 10 # => 5
Arguments¶
- $1 (int): Value to clamp
- $2 (int): Minimum bound (inclusive)
- $3 (int): Maximum bound (inclusive)
Exit codes¶
- 0: Always; 1 Missing argument
Output on stdout¶
- Clamped value