Smithy CNC Mills User Manual
Page 10

SmithyCNC Programmer’s Reference Manual:Language Overview
SmithyCNC Programmer’s Reference Manual: Language Overview
1-6
1.3.3 Expressions and Binary Operations
An expression is a set of characters starting with a left bracket [ and ending
with a balancing right bracket ]. In between the brackets are numbers, parame-
ter values, mathematical operations, and other expressions. An expression may
be evaluated to produce a number. The expressions on a line are evaluated
when the line is read, before anything on the line is executed. An example of an
expression is [ 1 + acos[0] - [#3 ** [4.0/2]]].
Binary operations appear only inside expressions. There are four basic mathe-
matical operations: addition (+), subtraction (-), multiplication (*), and division
(/). There are three logical operations: non-exclusive or (OR), exclusive or
(XOR), and logical and (AND). The eighth operation is the modulus operation
(MOD). The ninth operation is the "power" operation (**) of raising the number
on the left of the operation to the power on the right. The relational operators
are equality (EQ), inequality (NE), strictly greater than (GT), greater than or
equal to (GE), strictly less than (LT), and less than or equal to (LE).
The binary operations are divided into three groups. The first group is: power.
The second group is: multiplication, division, and modulus. The third group is:
addition, subtraction, logical non-exclusive or, logical exclusive or, and logical
and. If operations are strung together (for example in the expression [2.0 / 31.5
- 5.5 / 11.0]), operations in the first group are to be performed before opera-
tions in the second group and operations in the second group before opera-
tionsin the third group. If an expression contains more than one operation from
the same group (such as the first / and * in the example), the operation on the
left is performed first. Thus, the example is equivalent to: [((2.0 / 3) * 1.5) -
(5.5 / 11.0)] , which simplifies to [1.0 - 0.5] , which is 0.5.
The logical operations and modulus are to be performed on any real numbers,
not just on integers. The number zero is equivalent to logical false, and anynon-
zero number is equivalent to logical true.
1.3.4 Unary Operation Value
A unary operation value is either "ATAN" followed by one expression divided by
another expression (for example "ATAN[2]/[1+3]") or any other unary operation
name followed by an expression (for example "SIN[90]"). The unary operations
are: ABS (absolute value), ACOS (arc cosine), ASIN (arc sine), ATAN (arc tan-
gent), COS (cosine), EXP (e raised to the given power), FIX (round down), FUP
(round up), LN (natural logarithm), ROUND (round to the nearest whole num-
ber), SIN (sine), SQRT (square root), and TAN (tangent). Arguments to unary
operations which take angle measures (COS, SIN, and TAN) are in degrees.