src/swipl-devel/packages/xpce/man/refmanual/md/binary_expression.md

class binary_expression {#class-binary_expression}

Binary arithmetic expression with <-left and <-right operants. Class binary_expression has the subclasses

| + | Addition                 |
| - | Subtraction and negation |

PCE expression objects are first of all designed for supporting graphics calculations. The intermediate results are calculated in fixed-point arithmetic (1/1024 resolution). The result is rounded to the nearest integer value.

Binary expressions are used by class = for the definition of equations used by class spatial. The are also used by class handle and class region to express locations in terms of the dimensions of a related graphical object. Finally, they may be used as function objects in methods.

Note that type conversion converts function objects (and thus also binary expressions) into the value they evaluate too. This implies that

send(Box, size, size(W+2, H+2))

Is a comfortable way to do (graphics) calculations in PCE/Prolog. It must be noted that

W1 is W + 2,
H1 is H + 2,
send(Box. size, size(W1, H1))

is, in generally faster as the first example creates two PCE expressions evaluates then and then destroys them again.

Bugs:

Evaluation of expressions is written in C, bypassing the message passing of PCE. This implies the user cannot define new expression classes.

@see class real @see class number

Instance variables {#class-binary_expression-instvars}

Send methods {#class-binary_expression-send}

Get methods {#class-binary_expression-get}



Try the rswipl package in your browser

Any scripts or data that you put into this service are public.

rswipl documentation built on June 16, 2026, 5:07 p.m.