- (minuend subtrahend -- difference)
Inputs
minuend: Left operand from which the right operand is subtracted.subtrahend: Right operand subtracted from the minuend.
Outputs
difference: Difference object.
This builtin accepts whole and real numbers. Both inputs are dereferenced and must be non-NIL. The operands must have the same schema.
Behavior
- Whole-number schemas use integer subtraction semantics.
- Real schemas use floating-point subtraction semantics.
- If both operands are known at compile time, the result is computed at compile time.
- If the subtrahend is known
0, the result follows the minuend's value and schema. - If the minuend is known
0and the schema is real, the result preserves the real schema of the subtrahend. If that subtrahend is unknown, the result remains unknown. - Otherwise, the builtin produces an unknown result of the same schema.
Example
{} () {} [
unknownReal: 2.5r32 dynamic;
"-- int32 --" printCompilerMessage
10 3 - printStack _:;
7 0 - printStack _:;
"-- zero with unknown real32 --" printCompilerMessage
0.0r32 unknownReal - printStack _:;
"-- real32 --" printCompilerMessage
0.0r32 2.5r32 - printStack _:;
5.0r32 2.5r32 - printStack _:;
] "main" exportFunction
Expected Output During Compilation
-- int32 --
7
7
-- zero with unknown real32 --
Real32
-- real32 --
-2.5r32
2.5r32
See also
*builtin(multiplicand multiplier -- product)Multiplies two numeric objects.+builtin(left right -- sum)Adds two numeric objects./builtin(dividend divisor -- quotient)Divides numeric objects within the same schema; Whole division stays whole, while Real schemas use floating division.modbuiltin(dividend divisor -- remainder)Computes the remainder of numeric division; signed Int, unsigned Nat, and Real objects each follow their own remainder semantics.negbuiltin(object -- negatedValue)Negates a signed Int or Real object and keeps the same schema.