____ ____ ____ ____ ||n |||i |||m |||f || ||__|||__|||__|||__|| |/__\|/__\|/__\|/__\|
The nimf num module provides helpers for dealing with numbers. By convention words within this module will begin with the prefix `num.`.
Signature: ( n -- +n )
Description: Eats a number from TOS and leaves its absolute value on the stack.
Signature: ( n -- -n )
Description: Eats a number from TOS and leaves a negative version of the number on the stack. If the number is already negative it will be returned to TOS unchanged.
Signature: ( n1 n2 -- min )
Description: Eats two numbers from TOS and leaves the lower of the two on the stack.
Signature: ( n1 n2 -- max )
Description: Eats two numbers from TOS and leaves the higher of the two on the stack.
Signature: ( value n1 n2 -- flag )
Description: Eats two numbers that act as a range and a value to check from TOS. Leaves a flag that indicates if the value falls between the start and end of the range (non-inclusive), on the stack. The range can be passed in any order (they will be swapped if necessary by the word).
Signature: ( value n1 n2 -- flag )
Description: Eats two numbers that act as a range and a value to check from TOS. Leaves a flag that indicates if the value falls between the start and end of the range (inclusive), on the stack. The range can be passed in any order (they will be swapped if necessary by the word).
Signature: ( n -- n )
Description: Eats a number from TOS and leaves the number of digits it contains. For example, 100 has 3 digits.
Note: For purposes of this word if a number is negative, the minus sign counts as a digit. -123 would be 4 digits. This is in place in order to provide display padding for numbers. If you would like to avoid this, it would be trivial to make a word that detects a negative number, gets the digit length, and subtracts one from it.
Signature: ( n width -- )
Description: Eats a number representing a width, in printable characters, and a number value from TOS. Leaves nothing on the stack. Prints the number with padding to the left in order to make the number + spaces take up the width value. If a number is already larger than the width it will be printed without any added spacing.
Signature: ( n width -- )
Description: Eats a number representing a width, in printable characters, and a number value from TOS. Leaves nothing on the stack. Prints the number with padding to the right in order to make the number + spaces take up the width value. If a number is already larger than the width it will be printed without any added spacing.
Signature: ( n -- flag )
Description: Eats a number from TOS and leaves a flag indicating if the number is equal to zero.
Signature: ( n -- flag )
Description: Eats a number from TOS and leaves a flag indicating if the number is less than zero.
Signature: ( n -- flag )
Description: Eats a number from TOS and leaves a flag indicating if the number is greater than zero.