6.5.7 Numeric comparison

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-0.2 “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-0.2 “greater-or-equal”
0< ( n – f ) core “zero-less-than”
0<= ( n – f ) gforth-0.2 “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-0.2 “zero-greater-or-equal”
u< ( u1 u2 – f ) core “u-less-than”
u<= ( u1 u2 – f ) gforth-0.2 “u-less-or-equal”
u> ( u1 u2 – f ) core-ext “u-greater-than”
u>= ( u1 u2 – f ) gforth-0.2 “u-greater-or-equal”
within ( u1 u2 u3 – f ) core-ext “within”

u2<u3 and u1 in [u2,u3) or: u2>=u3 and u1 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-0.2 “d-less-or-equal”
d<> ( d1 d2 – f ) gforth-0.2 “d-not-equals”
d= ( d1 d2 – f ) double “d-equals”
d> ( d1 d2 – f ) gforth-0.2 “d-greater-than”
d>= ( d1 d2 – f ) gforth-0.2 “d-greater-or-equal”
d0< ( d – f ) double “d-zero-less-than”
d0<= ( d – f ) gforth-0.2 “d-zero-less-or-equal”
d0<> ( d – f ) gforth-0.2 “d-zero-not-equals”
d0= ( d – f ) double “d-zero-equals”
d0> ( d – f ) gforth-0.2 “d-zero-greater-than”
d0>= ( d – f ) gforth-0.2 “d-zero-greater-or-equal”
du< ( ud1 ud2 – f ) double-ext “d-u-less-than”
du<= ( ud1 ud2 – f ) gforth-0.2 “d-u-less-or-equal”
du> ( ud1 ud2 – f ) gforth-0.2 “d-u-greater-than”
du>= ( ud1 ud2 – f ) gforth-0.2 “d-u-greater-or-equal”