Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Conklin E.K.Forth programmer's handbook.2000.pdf
Скачиваний:
321
Добавлен:
23.08.2013
Размер:
2.04 Mб
Скачать

 

 

Forth Programmer’s Handbook

XOR

( x1 x2 — x3 )

Core

 

Return x3, the bit-by-bit exclusive or of x1 with x2. The phrase -1 XOR is equiv-

 

alent to INVERT (one’s complement of the input value).

 

 

Double-Precision Logical Operations

 

DABS

( d — +d )

Double

 

Return the absolute value of a double-precision stack value.

 

DMAX

( d1 d2 — d3 )

Double

 

Return d3, the larger of d1 and d2.

 

DMIN

( d1 d2 — d3 )

Double

 

Return d3, the lesser of d1 and d2.

 

DNEGATE

( d — -d )

Double

 

Change the sign of a double-precision stack value. Analogous to NEGATE.

 

2.2.3

Comparison and Testing Operations

 

These operations leave on the stack a number that is based upon a test of the contents of one or more items on top of the stack. In general, the test is destructive, in that it replaces the item(s) tested with the numerical results of the test. All numbers in Forth may be interpreted as true or false values; zero equals false, and any non-zero value equals true. The words below, which perform explicit tests, return -1 for true. Comparison and testing operations generally precede an IF, WHILE, or UNTIL construct.

You may also use - (minus) or D- as a not-equal test, because they return a non-

!zero difference if the two singleor double-precision numbers are unequal.

Glossary

 

 

0<

( n — flag )

Core

 

Return flag, which is true if and only if n is less than zero. “zero-less-than”

 

Forth Fundamentals 45

Forth Programmer’s Handbook

0<>

( n — flag )

Core Ext

 

Return flag, which is true if and only if n is not equal to zero. “zero-not-equal”

0=

( n — flag )

Core

 

Return flag, which is true if and only if n is equal to zero. “zero-equal”

0>

( n — flag )

Core Ext

 

Return flag, which is true if and only if n is greater than zero. “zero-greater-than”

<

( n1 n2 — flag )

Core

 

Return flag, which is true if and only if n1 is less than n2. “less-than”

 

<>

( n1 n2 — flag )

Core Ext

 

Return flag, which is true if and only if n1 is not equal to n2. “not-equal”

=

( n1 n2 — flag )

Core

 

Return flag, which is true if and only if n1 is equal to n2. “equal”

 

>

( n1 n2 — flag )

Core

 

Return flag, which is true if and only if n1 is greater than n2. “greater-than”

D0<

( d — flag )

Double

 

Return flag, which is true if and only if the double-precision value d is less than

 

zero. “D-zero-less”

 

D0=

( d — flag )

Double

 

Return flag, which is true if and only if the double-precision value d is equal to

 

zero. “D-zero-equal”

 

D<

( d1 d2 — flag )

Double

 

Return flag, which is true if and only if d1 is less than d2. “D-less-than”

D=

( d1 d2 — flag )

Double

 

Return flag, which is true if and only if d1 is equal to d2. “D-equals”

 

DU<

( ud1 ud2 — flag )

Double Ext

 

Return flag, which is true if and only if ud1 is less than ud2. “D-U-less”

FALSE

( — flag )

Core Ext

 

Return a flag that is false (binary zero).

 

46 Forth Fundamentals

Соседние файлы в предмете Электротехника