CS208, Wednesday 12 Jan 2022
Coming up
- Today: integers, byte order, characters, general advice
- Friday: debugging C with gdb
Write these integers in decimal
- 0xA3D =
- 0456 =
- 0b1011101 =
Write these decimal integers as...
- 37 = 0x?
- 37 = 0b?
- 37 = 0?
- 419 = 0x?
- 419 = 0b?
- 419 = 0?
Two's complement integers
- Odometer & counting
- Adding in binary
- Why 2's comp instead of signed magnitude?
- Negating a 2's comp integer
- Converting between 2's comp and decimal
Try it
- 8-bit 2's comp: 0x73 = ? (decimal)
- 8-bit 2's comp: 0x83 = ? (decimal)
- 32-bit 2's comp: 0xFFFFFFA5 = ? (decimal)
- (try that previous one two ways: bit-flipping vs. what to add to get 0)
- -57 = ? (8-bit 2's comp)
- -57 = ? (32-bit 2's comp)
Byte order
- (Here we are again: memory as sequence of addressed bytes)
- How do you store the 32-bit integer 20 = 0x00000014?
- Little-endian
- Big-endian
- Jonathan Swift
- On Holy Wars and a Plea for Peace by Danny Cohen, 1 April 1980
Miscellaneous thoughts
- Amount & importance of reading
- What Jeff writes
- Textbook readings
- Other readings
- Exams & assignments as values statements
- Using my code samples
- Run them
- Read them (what don't you get?)
- Modify them (play with them)
- (Sometimes) use them to start assignments
- Questions about either the past or the upcoming C assignments?