Monash University >
School
of Computer Science and Software Engineering >
CSE1303 >
Part B >
Lectures > Lecture B05 notes
CSE1303 Computer Science
Semester 2, 2003
Part B
Lecture B05 notes: Words, bits and pieces
In this lecture
- Byte order
- Little endian: least significant byte stored at lowest address
- Big endian: most significant byte stored at lowest address
- Bitwise operations
- Bitwise NOT (~)
- Bitwise AND (&)
- Bitwise OR (|)
- Bitwise exclusive OR (XOR) (^)
- Masking
- Use AND to extract bits
- Use AND to clear bits to 0
- Use OR to set bits to 1
- Use XOR to toggle bit values
- Shifting
- Shift left (<<)
- Shift right (>>)
- Arithmetic shift right for signed values (preserves MSB)
- Logical shift right for unsigned/non-numeric values (sets MSB
to 0)
- Relationship to multiplication and division
- Shift left: multiplication by powers of 2
- Shift right: division by powers of 2
[ Top |
Home ]
Last modified 2002-12-04