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

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

View Full Document Right Arrow Icon
20. LOW-LEVEL PROGRAMMING
Background image of page 1

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

View Full DocumentRight Arrow Icon
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.
Background image of page 2
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) */
Background image of page 3

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

View Full DocumentRight Arrow Icon
Other Bitwise Operators • The other bitwise operators are: ~ bitwise not ^ bitwise xor | bitwise or
Background image of page 4
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) */
Background image of page 5

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

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 07/08/2011 for the course CGS 3460 taught by Professor Staff during the Summer '08 term at University of Florida.

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 Right Arrow Icon
Ask a homework question - tutors are online