8ć15, 6 shift operations – Rockwell Automation 1775-S4B,D17756.5.3 User Manual SCANNER/MSG HND User Manual
Page 83

Using Symbols and Expressions
in Report Generation
Chapter 8
8Ć15
Report generation supports the following shift operators:
<<—Bit shift left
>>—Bit shift right
The shift operators shift binary values a specified number of bit positions
to the left or right.
When executing a bit shift left, a 0 shifts into the right most bit. When
executing a bit shift right, the left most bit does not change state. If the left
most bit is a 0, a 0 shifts in. Thus, the sign on the value will not change due
to a shift operation.
Some examples using bit shift operations are given below:
The following command lines show the execution of the bit shift left
operator:
A=5
B=(A<<1)
P A
P B
The 1775-S4B scanner prints out 5 for user symbol A and 2 for user
symbol B which is a bit shift left operation on user symbol A.
The bit patterns for the two values are given below:
User Symbol
Value Stored
Bit Pattern (32Ćbits)
A
B
5
2
00...00000101
00...00000010
The following command lines show the execution of the bit shift right
operator:
A=5
B=(A>>1)
P A
P B
The 1775-S4B scanner prints out 5 for user symbol A and 10 for user
symbol B which is a bit shift right operation on user symbol A.
8.5.6
Shift Operations