COMP1917: 07 Binary and Hexadecimal

COMP1917: 07 Binary and Hexadecimal
Sim Mautner
[email protected]
August 7, 2016
Sim Mautner (UNSW)
COMP1917: 07 Binary and Hexadecimal
August 7, 2016
1/6
Introduction
Computers store values in 0s and 1s. (Binary or base 2)
Sim Mautner (UNSW)
COMP1917: 07 Binary and Hexadecimal
August 7, 2016
2/6
Introduction
Computers store values in 0s and 1s. (Binary or base 2)
We think of numbers using digits 0-9 inclusive. (Decimal or base 10)
Sim Mautner (UNSW)
COMP1917: 07 Binary and Hexadecimal
August 7, 2016
2/6
Introduction
Computers store values in 0s and 1s. (Binary or base 2)
We think of numbers using digits 0-9 inclusive. (Decimal or base 10)
To ease our reading of binary values, we sometimes use hexadecimal:
Sim Mautner (UNSW)
COMP1917: 07 Binary and Hexadecimal
August 7, 2016
2/6
Introduction
Computers store values in 0s and 1s. (Binary or base 2)
We think of numbers using digits 0-9 inclusive. (Decimal or base 10)
To ease our reading of binary values, we sometimes use hexadecimal:
I
Hex, or base 16
Sim Mautner (UNSW)
COMP1917: 07 Binary and Hexadecimal
August 7, 2016
2/6
Introduction
Computers store values in 0s and 1s. (Binary or base 2)
We think of numbers using digits 0-9 inclusive. (Decimal or base 10)
To ease our reading of binary values, we sometimes use hexadecimal:
I
I
Hex, or base 16
0-9 and A-F inclusive (A=10, B=11, C=12 ...)
Sim Mautner (UNSW)
COMP1917: 07 Binary and Hexadecimal
August 7, 2016
2/6
Introduction
Computers store values in 0s and 1s. (Binary or base 2)
We think of numbers using digits 0-9 inclusive. (Decimal or base 10)
To ease our reading of binary values, we sometimes use hexadecimal:
I
I
Hex, or base 16
0-9 and A-F inclusive (A=10, B=11, C=12 ...)
Sim Mautner (UNSW)
COMP1917: 07 Binary and Hexadecimal
August 7, 2016
2/6
Skills to Cover (Binary and Decimal)
Conversion:
I
Decimal to Binary
F
Subtraction method
Sim Mautner (UNSW)
COMP1917: 07 Binary and Hexadecimal
August 7, 2016
3/6
Skills to Cover (Binary and Decimal)
Conversion:
I
Decimal to Binary
F
F
Subtraction method
Division method
Sim Mautner (UNSW)
COMP1917: 07 Binary and Hexadecimal
August 7, 2016
3/6
Skills to Cover (Binary and Decimal)
Conversion:
I
Decimal to Binary
F
F
I
Subtraction method
Division method
Binary to Decimal
Sim Mautner (UNSW)
COMP1917: 07 Binary and Hexadecimal
August 7, 2016
3/6
Skills to Cover (Binary and Decimal)
Conversion:
I
Decimal to Binary
F
F
I
Subtraction method
Division method
Binary to Decimal
Addition of binary numbers
Sim Mautner (UNSW)
COMP1917: 07 Binary and Hexadecimal
August 7, 2016
3/6
Skills to Cover (Hexadecimal)
Conversion:
I
Binary to Hex
Sim Mautner (UNSW)
COMP1917: 07 Binary and Hexadecimal
August 7, 2016
4/6
Skills to Cover (Hexadecimal)
Conversion:
I
I
Binary to Hex
Hex to Binary
Sim Mautner (UNSW)
COMP1917: 07 Binary and Hexadecimal
August 7, 2016
4/6
Negative Numbers in Binary
Representation in Two’s Complement
Sim Mautner (UNSW)
COMP1917: 07 Binary and Hexadecimal
August 7, 2016
5/6
Negative Numbers in Binary
Representation in Two’s Complement
Conversion:
I
”Flip the bits (binary digits) and add one”
Sim Mautner (UNSW)
COMP1917: 07 Binary and Hexadecimal
August 7, 2016
5/6
Negative Numbers in Binary
Representation in Two’s Complement
Conversion:
I
I
”Flip the bits (binary digits) and add one”
Decimal to Binary
Sim Mautner (UNSW)
COMP1917: 07 Binary and Hexadecimal
August 7, 2016
5/6
Negative Numbers in Binary
Representation in Two’s Complement
Conversion:
I
I
I
”Flip the bits (binary digits) and add one”
Decimal to Binary
Binary to Decimal
Sim Mautner (UNSW)
COMP1917: 07 Binary and Hexadecimal
August 7, 2016
5/6
Negative Numbers in Binary
Representation in Two’s Complement
Conversion:
I
I
I
”Flip the bits (binary digits) and add one”
Decimal to Binary
Binary to Decimal
Subtraction of Binary Numbers
Sim Mautner (UNSW)
COMP1917: 07 Binary and Hexadecimal
August 7, 2016
5/6
Overflows
8 bit, signed:
I
127 + 1 = ?
Sim Mautner (UNSW)
COMP1917: 07 Binary and Hexadecimal
August 7, 2016
6/6
Overflows
8 bit, signed:
I
I
127 + 1 = ?
-128 - 1 = ?
Sim Mautner (UNSW)
COMP1917: 07 Binary and Hexadecimal
August 7, 2016
6/6