/ (dividend divisor -- quotient)
Inputs
dividend: Numeric object being divided.divisor: Numeric object dividing the dividend to produce the quotient.
Outputs
quotient: Quotient object.
/ computes numeric division. Both inputs are dereferenced, must be non-NIL, and must have the same numeric schema.
Behavior
- Int uses signed integer division and keeps the same signed Whole schema.
- Nat uses unsigned integer division and keeps the same unsigned Whole schema.
- Real uses floating division and keeps the same real schema.
- Whole-number division stays in the same Whole schema. It does not widen to Real.
- If the divisor is known to be
0, the builtin is invalid. - If the dividend is the known minimum value of a signed Whole schema and the divisor is known
-1, the builtin is invalid because the result overflows. - If both operands are known at compile time and the operation is valid, the result is computed at compile time.
- For unknown operands the operation is performed at run time without a zero-divisor or overflow check.
- If either operand is unknown, the result is an unknown value of the same numeric schema.
Example
{} () {} [
"-- int32 --" printCompilerMessage
8 2 / printStack _:;
7 2 / printStack _:;
-7 2 / printStack _:;
"-- nat32 --" printCompilerMessage
7n32 2n32 / printStack _:;
"-- real32 --" printCompilerMessage
7.5r32 2.5r32 / printStack _:;
"-- unknown int32 --" printCompilerMessage
value: 0 dynamic;
value 2 / printStack _:;
] "main" exportFunction
Expected Output During Compilation
-- int32 --
4
3
-3
-- nat32 --
3n32
-- real32 --
3.0r32
-- unknown int32 --
Int32