Expressions
===========
`gtroff' has most arithmetic operators common to other languages:
* Arithmetic: `+' (addition), `-' (subtraction), `/' (division), `*'
(multiplication), `%' (modulo).
`gtroff' only provides integer arithmetic. The internal type used
for computing results is `int', which is usually a 32bit signed
integer.
* Comparison: `<' (less than), `>' (greater than), `<=' (less than
or equal), `>=' (greater than or equal), `=' (equal), `==' (the
same as `=').
* Logical: `&' (logical and), `:' (logical or).
* Unary operators: `-' (negating, i.e. changing the sign), `+' (just
for completeness; does nothing in expressions), `!' (logical not;
this works only within `if' and `while' requests). See below for
the use of unary operators in motion requests.
* Extrema: `>?' (maximum), `<?' (minimum). For example, `5>?3'
yields `5'.
* Scaling: `(C;E)'. Evaluate E using C as the default scaling
indicator. If C is missing, ignore scaling indicators in the
evaluation of E.
Parentheses may be used as in any other language. However, in
`gtroff' they are necessary to ensure order of evaluation. `gtroff'
has no operator precedence; expressions are evaluated left to right.
This means that `gtroff' evaluates `3+5*4' as if it were parenthesized
like `(3+5)*4', not as `3+(5*4)', as might be expected.
For many requests which cause a motion on the page, the unary
operators work differently. The `+' and `-' operators then indicate a
motion relative to the current position (down or up, respectively), and
the `|' operator indicates an absolute position on the page or input
line. `+' and `-' are also treated differently by the following
requests and escapes: `bp', `in', `ll', `lt', `nm', `nr', `pl', `pn',
`po', `ps', `rt', `ti', `\R', and `\s'. Here the plus and minus signs
indicate increments and decrements.
Note:Setting Registers.
Due to the way arguments are parsed, spaces are not allowed in
expressions, unless the entire expression is surrounded by parentheses.
Note:Request Arguments, and Note:Conditionals and Loops.