{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# 20 - 20 LOW-LEVEL PROGRAMMING Bitwise Shift Operators The...

This preview shows pages 1–6. Sign up to view the full content.

20. LOW-LEVEL PROGRAMMING

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Bitwise Shift Operators • The bitwise shift operators are: << left shift >> right shift • The expression i << j represents i shifted left j positions, zero-filled. • The expression i >> j represents i shifted right j positions. If i is of an unsigned type or if the value of i is not negative, then zero bits are added at the left as needed. If i is negative, the result depends on the implementation.
Bitwise Shift Operators • For portability, it’s best to perform shifts only on unsigned numbers. • Examples: unsigned short int i, j; i = 13; /* i is now 13 (binary 0000000000001101) */ j = i << 2; /* j is now 52 (binary 0000000000110100) */ j = i >> 2; /* j is now 3 (binary 0000000000000011) */

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Other Bitwise Operators • The other bitwise operators are: ~ bitwise not ^ bitwise xor | bitwise or
Other Bitwise Operators • Examples: unsigned short int i, j, k; i = 21; /* i is now 21 (binary 0000000000010101) */ j = 56; /* j is now 56 (binary 0000000000111000) */

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 8

20 - 20 LOW-LEVEL PROGRAMMING Bitwise Shift Operators The...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online