www.delorie.com/gnu/docs/gforth/gforth_17.html | search |
Buy GNU books! | |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The words +
, -
, *
, /
, and mod
always
operate on the top two stack items:
2 2 .s + .s . 2 1 - . 7 3 mod . |
The operands of -
, /
, and mod
are in the same order
as in the corresponding infix expression (this is generally the case in
Forth).
Parentheses are superfluous (and not available), because the order of the words unambiguously determines the order of evaluation and the operands:
3 4 + 5 * . 3 4 5 * + . |
6-7*8+9
in Forth notation(3).
To change the sign, use negate
:
2 negate . |
/mod
performs both /
and mod
.
7 3 /mod . . |
Reference: 5.5 Arithmetic.
webmaster | delorie software privacy |
Copyright © 2003 by The Free Software Foundation | Updated Jun 2003 |