Sha256: 1b77cbe6e2da96f76f683f45d200db30c8b6518b9684e0dcc1b60873641ae3c7

Contents?: true

Size: 881 Bytes

Versions: 10

Compression:

Stored size: 881 Bytes

Contents

To keep the example simple, the word takes the two numbers from the stack.  '''/mod''' returns two results; the stack effect is ( a b -- a%b a/b ).
: arithmetic ( a b -- )
  cr ." a=" over . ." b=" dup .
  cr ." a+b=" 2dup + .
  cr ." a-b=" 2dup - .
  cr ." a*b=" 2dup * .
  cr ." a/b=" /mod .
  cr ." a mod b = " . cr ;

Different host systems have different native signed division behavior. ANS Forth defines two primitive double-precision signed division operations, from which the implementation may choose the most natural to implement the basic divide operations ( / , /mod , mod , */ ). This is partly due to differing specifications in the two previous standards, Forth-79 and Forth-83.

FM/MOD ( d n -- mod div )   \ floored
SM/REM ( d n -- rem div )   \ symmetric
M* ( n n -- d )

In addition, there are unsigned variants.

UM/MOD ( ud u -- umod udiv )
UM* ( u u -- ud )

Version data entries

10 entries across 7 versions & 1 rubygems

Version Path
zettacode-0.1.7 files.zettacode/arithmetic.integer/forth.txt
zettacode-0.1.6 files.zettacode/arithmetic.integer/forth.txt
zettacode-0.1.6 files.zettacode2/arithmetic.integer/forth.txt
zettacode-0.1.5 files.zettacode/arithmetic.integer/forth.txt
zettacode-0.1.5 files.zettacode2/arithmetic.integer/forth.txt
zettacode-0.1.4 files.zettacode/arithmetic.integer/forth.txt
zettacode-0.1.4 files.zettacode2/arithmetic.integer/forth.txt
zettacode-0.1.3 files.zettacode/arithmetic.integer/forth.txt
zettacode-0.1.2 files.zettacode/arithmetic.integer/forth.txt
zettacode-0.1.1 zettacode.files/arithmetic.integer/forth.txt