问题描述
我知道AND字定义了二进制and
...,但是什么定义了逻辑and
?
I know the AND word defines binary and
... but what defines logical and
?
推荐答案
相同的词AND
也用于逻辑和.但是,建议AND
的两个输入值是格式正确的标志; true 和 false 由两个值表示,位全部置为(-1),位全部未置为(0).除此以外的其他值可能都适用(如C中所述),但可能会导致细微的错误.
The same word, AND
, is also used for logical and. But the two input values to AND
are recommended to be well-formed flags; true and false are represented by two values, bits all set (-1) and bits all unset (0). Other values than these may work as true (as in C), but may lead to subtle errors.
所有比较运算符均返回格式正确的标志,但例如,-
则不返回.以下结果为假(0).
All comparison operators return well-formed flags, but for instance -
does not. The following evaluates to false (0).
7 5 - 7 3 - AND
AND
的位模式为100和010.结果为0(按位的和一样).
AND
gets bit patterns 100 and 010. The result is 0 (as it does the bitwise and).
参考文献:
- Forth中的位操作,是 Learning Forth Bit的一部分按位.
- 第4章 em>起步.
- Bit Manipulations in Forth, part of Learning Forth Bit by Bit.
- Section "A Little Logic" in Chapter 4 of Starting Forth.
这篇关于逻辑与在Forth?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!