The Forth code
7 3 > . (7 > 3)
returns -1
, but every other language I've ever used uses 1
as a flag for true. Why is this? What accounts for this difference?
-1 is all bits set which then has the benefit that words such as and
, or
, not
, ... serve as both logical and bitwise operators (as opposed to say C with &&
, ||
, !
, ... vs. &
, |
, ~
, ...)