CS 111 w20 lecture 22 outline

1 binary

  • base 10 vs base 2
  • what is a bit?
    • How many bits would be need to represent the numbers 0 to 63?
    • images we've been working with have been 24-bit (8 bits for each color channel)
  • practice conversions:
    • 9 and 42 to binary
    • 00111010 and 01000011 to decimal
    • add 00001001 and 00001110

2 hexadecimal

  • base 16
    • since a single digit in base 16 can be any number between 0 and 15 in base 10, we need new symbols for the numbers beyond 9
    • a, b, c, d, e, f are used for 10, 11, 12, 13, 14, and 15, respectively
  • how many bits per hexadecimal digit?
  • you often see colors written in hexadecimal, with two digits for each color (8 bits)
    • still in RGB order
    • ff0000 is max red, no green or blue
  • practice arithmetic