Arithmetic (+ - * / %)
Adding, subtracting, multiplying and dividing numbers and positions, and the remainder of a division.
Syntax
a + b
a - b
a * b
a / b
a % b
Result
A number or a position.
Examples
In the example drawing:
| Expression | Gives |
|---|---|
2+3*4 |
14 |
L-2 |
498 |
P2-P1 |
[0,300] |
(P2-P1)/2 |
[0,150] |
P1+[0,10] |
[500,10] |
P2*2 |
[1000,600] |
P1*ROTATE(P0,90) |
[0,500] |
17 % 5 |
2 |
-30 % 360 |
330 |
7.5 % 2 |
1.5 |
L % 3 |
2 |
1/3+1 |
1 1/3 |
3'/4 |
9" |
Notes
Positions add and subtract as steps: P2-P1 is the step from P1 to P2, and P1+(P2-P1)/2 is half way between them. A position times a number scales it. A position times a transformation (ROTATE, TRANSLATE …) moves it. + also joins two strings (a fraction or feet and inches is joined as written: "W="+1/4 is "W=1/4").
Fractions and feet and inches stay exact where they can: 1/3+1 is 1 1/3, 7/2 % 1 is 1/2, 2*1' is 2', 3'/4 is 9" and 3'/6" is 6. See Numbers. A fraction divided by 0 is an error.
a % b is the remainder when a is divided by b. It always has the sign of b, so an angle A % 360 is between 0 and 360 whatever A is. % 0 is an error. % binds as tightly as * and /: 2+7%3 is 3, and #DD%7 is the remainder of the dimension distance (system variables start with #).