Print

Shift / Rotate

Shift/Rotate

The Shift and Rotate functions provide a mechanism for shifting or rotating bits in an integer number.

The Shift function allows you to shift an integer number left or right, a selected number of bit positions. A bit value that you choose is shifted into the vacated bit position(s). For signed integers, the shift can be defined to include or exclude the sign bit (the most significant bit).

The Rotate function is similar to the Shift. The difference is that the bits that are shifted out of one end of the number are shifted back into the vacated position(s) on the other end.

Shift (unsigned number)

When you place a Shift/Rotate block, select the Shift button in the dialog box. A graphic showing the Shift operation will be displayed . Select the direction that you want to Shift. If you change the direction, the graphic will change to reflect the shifted direction. Select the Tag that you want to Shift, as Output. Select the bit value that you want to Shift into the vacated bit position. If you are shifting more than one bit position, this value will be shifted into all of the vacated bits. Lastly, select the number of bit positions to Shift.

Shift (signed number)

There is an additional option, when Shifting a signed number. When you select a signed integer tagname, a checkbox will pop onto the dialog box, which says “Exclude Sign Bit”. If you check, it the Shift operation will not include the sign bit (the most significant bit position). In other words, if you check the box, the sign bit will remain unchanged. If you are shifting right and check the box, the bit that is shifted in will be shifted into the second most significant bit position. If you uncheck the Exclude Sign Bit box, shifting will include the entire number.

Rotate (unsigned number)

When you place a Shift/Rotate block, select the Rotate button in the dialog box. The Rotate operation will be displayed in the dialog box. Select the direction that you want to Rotate. If you change the direction, the graphic will change to reflect the rotated direction. Select the Tag you want to Rotate, as Output. The bit rotated out will be rotated back in to the vacant bit position on the opposite end of the variable. Lastly, select the number of bit positions to Rotate.

Rotate (signed number)

There is an additional option, when Rotating a signed number. When you select a signed integer tagname, a checkbox will pop onto the dialog box, which says “Exclude Sign Bit”. If you check it the Rotate operation will not include the sign bit (the most significant bit position). In other words, if you check the box, the sign bit will remain unchanged. If you are rotating right and check the box, the bit that is rotated in will be rotated into the second most significant bit position. If you uncheck the Exclude Sign Bit box, rotating will include the entire number.