1
0
mirror of https://github.com/mgcaret/of816.git synced 2024-12-28 10:30:21 +00:00
of816/test/7.3.2.3.fs
2020-01-06 10:13:52 -08:00

188 lines
5.8 KiB
Forth

DECIMAL
0 INVERT CONSTANT 1SD
1SD 1 RSHIFT CONSTANT MAX-INTD \ 01...1
MAX-INTD INVERT CONSTANT MIN-INTD \ 10...0
MAX-INTD 2/ CONSTANT HI-INT \ 001...1
MIN-INTD 2/ CONSTANT LO-INT \ 110...1
1SD MAX-INTD 2CONSTANT MAX-2INT \ 01...1
0 MIN-INTD 2CONSTANT MIN-2INT \ 10...0
MAX-2INT 2/ 2CONSTANT HI-2INT \ 001...1
MIN-2INT 2/ 2CONSTANT LO-2INT \ 110...0
testing 7.3.2.3 Double number arithmetic
T{ 0 S>D -> 0 0 }T
T{ 1 S>D -> 1 0 }T
T{ 2 S>D -> 2 0 }T
T{ -1 S>D -> -1 -1 }T
T{ -2 S>D -> -2 -1 }T
T{ MIN-INT S>D -> MIN-INT -1 }T
T{ MAX-INT S>D -> MAX-INT 0 }T
TESTING D+ with small integers
t{ 0 s>d 5 s>d D+ -> 5 s>d }t
t{ -5 s>d 0 s>d D+ -> -5 s>d }t
t{ 1 s>d 2 s>d D+ -> 3 s>d }t
t{ 1 s>d -2 s>d D+ -> -1 s>d }t
t{ -1 s>d 2 s>d D+ -> 1 s>d }t
t{ -1 s>d -2 s>d D+ -> -3 s>d }t
t{ -1 s>d 1 s>d D+ -> 0 s>d }t
TESTING D+ with mid range integers
T{ 0 0 0 5 D+ -> 0 5 }T
T{ -1 5 0 0 D+ -> -1 5 }T
T{ 0 0 0 -5 D+ -> 0 -5 }T
T{ 0 -5 -1 0 D+ -> -1 -5 }T
T{ 0 1 0 2 D+ -> 0 3 }T
T{ -1 1 0 -2 D+ -> -1 -1 }T
T{ 0 -1 0 2 D+ -> 0 1 }T
T{ 0 -1 -1 -2 D+ -> -1 -3 }T
T{ -1 -1 0 1 D+ -> -1 0 }T
T{ MIN-INTD 0 2DUP D+ -> 0 1 }T
T{ MIN-INTD S>D MIN-INTD 0 D+ -> 0 0 }T
TESTING D+ with large double integers
t{ HI-2INT 1 s>d D+ -> 0 HI-INT 1+ }t
T{ HI-2INT 2DUP D+ -> 1SD 1- MAX-INTD }T
t{ MAX-2INT MIN-2INT D+ -> -1 s>d }t
T{ MAX-2INT LO-2INT D+ -> HI-2INT }T
t{ HI-2INT MIN-2INT D+ 1 s>d D+ -> LO-2INT }t
T{ LO-2INT 2DUP D+ -> MIN-2INT }T
TESTING D- with small integers
t{ 0 s>d 5 s>d D- -> -5 s>d }t
t{ 5 s>d 0 s>d D- -> 5 s>d }t
t{ 0 s>d -5 s>d D- -> 5 s>d }t
t{ 1 s>d 2 s>d D- -> -1 s>d }t
t{ 1 s>d -2 s>d D- -> 3 s>d }t
t{ -1 s>d 2 s>d D- -> -3 s>d }t
t{ -1 s>d -2 s>d D- -> 1 s>d }t
t{ -1 s>d -1 s>d D- -> 0 s>d }t
TESTING D- with mid-range integers
T{ 0 0 0 5 D- -> 0 -5 }T
T{ -1 5 0 0 D- -> -1 5 }T
T{ 0 0 -1 -5 D- -> 1 4 }T
T{ 0 -5 0 0 D- -> 0 -5 }T
T{ -1 1 0 2 D- -> -1 -1 }T
T{ 0 1 -1 -2 D- -> 1 2 }T
T{ 0 -1 0 2 D- -> 0 -3 }T
T{ 0 -1 0 -2 D- -> 0 1 }T
T{ 0 0 0 1 D- -> 0 -1 }T
t{ MIN-INTD 0 2DUP D- -> 0 s>d }t
T{ MIN-INTD S>D MAX-INTD 0 D- -> 1 1SD }T
TESTING D- with large integers
t{ MAX-2INT MAX-2INT D- -> 0 s>d }t
t{ MIN-2INT MIN-2INT D- -> 0 s>d }t
T{ MAX-2INT HI-2INT D- -> LO-2INT DNEGATE }T
T{ HI-2INT LO-2INT D- -> MAX-2INT }T
t{ LO-2INT HI-2INT D- -> MIN-2INT 1 s>d D+ }t
t{ MIN-2INT MIN-2INT D- -> 0 s>d }t
T{ MIN-2INT LO-2INT D-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 1 S>D 1 FM/MOD -> 0 1 }T
T{ 2 S>D 1 FM/MOD -> 0 2 }T
T{ -1 S>D 1 FM/MOD -> 0 -1 }T
T{ -2 S>D 1 FM/MOD -> 0 -2 }T
T{ 0 S>D -1 FM/MOD -> 0 0 }T
T{ 1 S>D -1 FM/MOD -> 0 -1 }T
T{ 2 S>D -1 FM/MOD -> 0 -2 }T
T{ -1 S>D -1 FM/MOD -> 0 1 }T
T{ -2 S>D -1 FM/MOD -> 0 2 }T
T{ 2 S>D 2 FM/MOD -> 0 1 }T
T{ -1 S>D -1 FM/MOD -> 0 1 }T
T{ -2 S>D -2 FM/MOD -> 0 1 }T
T{ 7 S>D 3 FM/MOD -> 1 2 }T
T{ 7 S>D -3 FM/MOD -> -2 -3 }T
T{ -7 S>D 3 FM/MOD -> 2 -3 }T
T{ -7 S>D -3 FM/MOD -> -1 2 }T
T{ MAX-INT S>D 1 FM/MOD -> 0 MAX-INT }T
T{ MIN-INT S>D 1 FM/MOD -> 0 MIN-INT }T
T{ MAX-INT S>D MAX-INT FM/MOD -> 0 1 }T
T{ MIN-INT S>D MIN-INT FM/MOD -> 0 1 }T
T{ 1S 1 4 FM/MOD -> 3 MAX-INT }T
T{ 1 MIN-INT M* 1 FM/MOD -> 0 MIN-INT }T
T{ 1 MIN-INT M* MIN-INT FM/MOD -> 0 1 }T
T{ 2 MIN-INT M* 2 FM/MOD -> 0 MIN-INT }T
T{ 2 MIN-INT M* MIN-INT FM/MOD -> 0 2 }T
T{ 1 MAX-INT M* 1 FM/MOD -> 0 MAX-INT }T
T{ 1 MAX-INT M* MAX-INT FM/MOD -> 0 1 }T
T{ 2 MAX-INT M* 2 FM/MOD -> 0 MAX-INT }T
T{ 2 MAX-INT M* MAX-INT FM/MOD -> 0 2 }T
T{ MIN-INT MIN-INT M* MIN-INT FM/MOD -> 0 MIN-INT }T
T{ MIN-INT MAX-INT M* MIN-INT FM/MOD -> 0 MAX-INT }T
T{ MIN-INT MAX-INT M* MAX-INT FM/MOD -> 0 MIN-INT }T
T{ MAX-INT MAX-INT M* MAX-INT FM/MOD -> 0 MAX-INT }T
T{ 0 S>D 1 SM/REM -> 0 0 }T
T{ 1 S>D 1 SM/REM -> 0 1 }T
T{ 2 S>D 1 SM/REM -> 0 2 }T
T{ -1 S>D 1 SM/REM -> 0 -1 }T
T{ -2 S>D 1 SM/REM -> 0 -2 }T
T{ 0 S>D -1 SM/REM -> 0 0 }T
T{ 1 S>D -1 SM/REM -> 0 -1 }T
T{ 2 S>D -1 SM/REM -> 0 -2 }T
T{ -1 S>D -1 SM/REM -> 0 1 }T
T{ -2 S>D -1 SM/REM -> 0 2 }T
T{ 2 S>D 2 SM/REM -> 0 1 }T
T{ -1 S>D -1 SM/REM -> 0 1 }T
T{ -2 S>D -2 SM/REM -> 0 1 }T
T{ 7 S>D 3 SM/REM -> 1 2 }T
T{ 7 S>D -3 SM/REM -> 1 -2 }T
T{ -7 S>D 3 SM/REM -> -1 -2 }T
T{ -7 S>D -3 SM/REM -> -1 2 }T
T{ MAX-INT S>D 1 SM/REM -> 0 MAX-INT }T
T{ MIN-INT S>D 1 SM/REM -> 0 MIN-INT }T
T{ MAX-INT S>D MAX-INT SM/REM -> 0 1 }T
T{ MIN-INT S>D MIN-INT SM/REM -> 0 1 }T
T{ 1S 1 4 SM/REM -> 3 MAX-INT }T
T{ 2 MIN-INT M* 2 SM/REM -> 0 MIN-INT }T
T{ 2 MIN-INT M* MIN-INT SM/REM -> 0 2 }T
T{ 2 MAX-INT M* 2 SM/REM -> 0 MAX-INT }T
T{ 2 MAX-INT M* MAX-INT SM/REM -> 0 2 }T
T{ MIN-INT MIN-INT M* MIN-INT SM/REM -> 0 MIN-INT }T
T{ MIN-INT MAX-INT M* MIN-INT SM/REM -> 0 MAX-INT }T
T{ MIN-INT MAX-INT M* MAX-INT SM/REM -> 0 MIN-INT }T
T{ MAX-INT MAX-INT M* MAX-INT SM/REM -> 0 MAX-INT }T