4 maxl shift operators, Additive operators, Shift operators – ElmoMC Multi-Axis Motion Controller-Maestro User Manual
Page 80
5.4.1.4.4 MAXL Shift Operators
The bitwise shift operators are:
• Right shift (>>)
• Left shift (<<)
These binary operators have left-to-right associativity.
Syntax
shift-expression :
expression << expression
expression >> expression
expression:
additive-expression
Both operands of the shift operators must be integer types. The type of the result is the
same as the type of the left operand. The value of a right-shift expression e1 >> e2 is e1
/ 2
e2
, and the value of a left-shift expression e1 << e2 is e1 * 2
e2
.
The results are undefined if the right operand of a shift expression is negative or if the
right operand is greater than or equal to the number of bits in the (promoted) left
operand.
The left-shift operator causes the bit pattern in the first operand to be shifted left by
the number of bits specified by the second operand. Bits vacated by the shift operation
are zero-filled. This is a logical shift, as opposed to a shift-and-rotate operation.
The right-shift operator causes the bit pattern in the first operand to be shifted right
the number of bits specified by the second operand. Bits vacated by the shift operation
are zero-filled for unsigned quantities. For signed quantities, the sign bit is propagated
into the vacated bit positions. The shift is a logical shift if the left operand is an
unsigned quantity; otherwise, it is an arithmetic shift.
Maestro
Software Manual
MAXL Program Language
MAN-MASSW (Ver. Q)
5-18