mod

mod (dividend divisor -- remainder)

Inputs

Outputs

mod computes the remainder of numeric division. Both inputs are dereferenced, must be non-NIL, and must have the same numeric schema.

Behavior

Example

{} () {} [
  "-- int32 --" printCompilerMessage
  7 3 mod printStack _:;
  -7 3 mod printStack _:;
  7 -3 mod printStack _:;

  "-- nat32 --" printCompilerMessage
  7n32 3n32 mod printStack _:;

  "-- real32 --" printCompilerMessage
  7.5r32 2.0r32 mod printStack _:;
  -7.5r32 2.0r32 mod printStack _:;
  7.5r32 -2.0r32 mod printStack _:;

  "-- unknown divisor --" printCompilerMessage
  divisor: 3 dynamic;
  7 divisor mod printStack _:;
] "main" exportFunction

Expected Output During Compilation

-- int32 --
1
-1
1
-- nat32 --
1n32
-- real32 --
1.5r32
-1.5r32
1.5r32
-- unknown divisor --
Int32

See also