Binary Representation
CSCI N35100
Andy Harris
Indiana University / Purdue University - Indianapolis
Computers and Information
- Information limited to on/off impulses
- Like a light switch
- Infinite positions
- Two outcomes
Working with Multiple Switches
- The
light switch demo
- One switch - two messages
- Two switches - four messages
- Three switches - eight messages
Assigning values to messages
- Looking at the pattern
- 1, 2, 4, 8, 16, 32, 64, 128...
- Seeing how it works
- The
brick counter demo
Converting from Binary to base 10
- Start with Grid
- Right to left
- Powers of Two
- Substitute 1 with appropriate value
Converting from Base 10 to Binary
- Start with grid
- Find highest value
- Subtract
- Repeat
Binary is good...
- Because it's the underlying format of computers
- But
- it's a pain to work with.
- 11001100001010
- Base 10 is more natural for humans
- Conversion is tedious
Base 8 characteristics
- Max: 7
- Min: 0
- Possible values: 8
3 Digits of binary
- Max: 7
- Min:0
- Possible values: 8
PATTERN!
- Whatever can be expressed in 3 digits of binary...
- Can be expressed in one digit of octal!
- 101 binary is 5 octal
- 010 binary is 2 octal
3 digits binary = 1 digit octal
- For three digits of binary,
- converting to octal -
- is just like converting to decimal
Converting Binary to Octal
Octal to Binary
- 45 base 8
- Turn each octal digit to 3 digits of binary:
- 421 421
- 100 101 binary
The problem with Octal
- Computers tend to work in bytes (8 bits)
- Octal prefers lengths of 6 or 9
- Eight bits fits in three digits of octal....
But what about 643 octal?
- It's possible to have a three digit octal
- that doesn't fit in a byte.
Four digits of Binary
- Max: 15
- Min: 0
- Number of values: 16
- This would be like base 16. (Hexadecimal)
But there's a problem...
- What about this value?
- 1100
- It comes out to 12 decimal,
- But 12 hex means 16 +2 = 18!!
We can't use base 10 place value here.
- We must 'invent' new numerals
- Letters can be used for numbers!
The Sneaky Solution
- 10: A
- 11: B
- 12: C
- 13: D
- 14: E
- 15: F