Node:Numeric comparison, Next:Mixed precision, Previous:Bitwise operations, Up:Arithmetic
Note that the words that compare for equality (= <> 0= 0<> d= d<>
d0= d0<>
) work for for both signed and unsigned numbers.
<
n1 n2 -- f core ``less-than''
<=
n1 n2 -- f gforth ``less-or-equal''
<>
n1 n2 -- f core-ext ``not-equals''
=
n1 n2 -- f core ``equals''
>
n1 n2 -- f core ``greater-than''
>=
n1 n2 -- f gforth ``greater-or-equal''
0<
n -- f core ``zero-less-than''
0<=
n -- f gforth ``zero-less-or-equal''
0<>
n -- f core-ext ``zero-not-equals''
0=
n -- f core ``zero-equals''
0>
n -- f core-ext ``zero-greater-than''
0>=
n -- f gforth ``zero-greater-or-equal''
u<
u1 u2 -- f core ``u-less-than''
u<=
u1 u2 -- f gforth ``u-less-or-equal''
u>
u1 u2 -- f core-ext ``u-greater-than''
u>=
u1 u2 -- f gforth ``u-greater-or-equal''
within
u1 u2 u3 -- f core-ext ``within''
u2=<u1<u3 or: u3=<u2 and u1 is not in [u3,u2). This works for
unsigned and signed numbers (but not a mixture). Another way to think
about this word is to consider the numbers as a circle (wrapping
around from max-u
to 0 for unsigned, and from max-n
to
min-n for signed numbers); now consider the range from u2 towards
increasing numbers up to and excluding u3 (giving an empty range if
u2=u3); if u1 is in this range, within
returns true.
d<
d1 d2 -- f double ``d-less-than''
d<=
d1 d2 -- f gforth ``d-less-or-equal''
d<>
d1 d2 -- f gforth ``d-not-equals''
d=
d1 d2 -- f double ``d-equals''
d>
d1 d2 -- f gforth ``d-greater-than''
d>=
d1 d2 -- f gforth ``d-greater-or-equal''
d0<
d -- f double ``d-zero-less-than''
d0<=
d -- f gforth ``d-zero-less-or-equal''
d0<>
d -- f gforth ``d-zero-not-equals''
d0=
d -- f double ``d-zero-equals''
d0>
d -- f gforth ``d-zero-greater-than''
d0>=
d -- f gforth ``d-zero-greater-or-equal''
du<
ud1 ud2 -- f double-ext ``d-u-less-than''
du<=
ud1 ud2 -- f gforth ``d-u-less-or-equal''
du>
ud1 ud2 -- f gforth ``d-u-greater-than''
du>=
ud1 ud2 -- f gforth ``d-u-greater-or-equal''