160 likes | 382 Views
Binary Arithmetic. CPSC 101: Chp 2 John Lamertina. Early Need to Count. One-to-One Sets. |||||||||||||||||||||||||||||. 27 pebbles ≡ 27 sheep. Counting in 10s. Up to TEN More than TEN?. Countable Sets of 10. 10. 10. 7. Why Decimal Numbers?. 10 fingers 10 digits (0,1,2,3,…,9)
E N D
Binary Arithmetic CPSC 101: Chp 2 John Lamertina
One-to-One Sets ||||||||||||||||||||||||||||| 27 pebbles ≡ 27 sheep
Counting in 10s Up to TEN More than TEN?
Countable Sets of 10 10 10 7
Why Decimal Numbers? • 10 fingers • 10 digits (0,1,2,3,…,9) • Countable Sets of 10 • Ones • Tens • Hundreds • Thousands • etc
Simple Decimal Number 27 = 20 + 7 = 2 tens + 7 ones = (2×10) + (7×1) = (2×101) + (7×100) Anything to the zero power is 1 Powers of 10
Another Decimal Number 9327 = 9000 + 300 +20 + 7 = 9 thousands + 3 hundreds + 2 tens + 7 ones = (9×1000) + (3×100) + (2×10) + (7×1) = (9×103) + (3×102) + (2×101) + (7×100) Powers of 10
A Decimal Number with Zeros 7009 = 7000 + 0 + 0 + 9 = 7 thousands + 0 hundreds + 0 tens + 9 ones = (7×1000) + (0×100) + (0×10) + (9×1) = (7×103) + (0×102) + (0×101) + (9×100) Powers of 10
Decimal vs Binary • Decimal numbers are powers of 10 • Deci = 10 • Binary numbers are powers of 2 • Bi = 2
Why Binary Numbers? • Electronic circuits have two possible states or values: Off and On • Off and On: Zero and One (0, 1) • Two digits (0, 1): binary number system • Thus computers operate on the binary number system
Simple Binary Number 1012 = 1002 + 02 + 12 = (1×22) + (0×21) + (1×20) Read “101, base 2” not 101 squared. Powers of 2
Simple Binary Number 1012 = 1002 + 02 + 12 = (1×22) + (0×21) + (1×20) = 410 + 010 + 110 = 510 1012 = 510
Simple Decimal Number vs Simple Binary Number 15 = 10 + 5 = 1 ten + 5 ones = (1×10) + (5×1) = (1×101) + (5×100) 11112 = 10002 + 1002 + 102 + 12 = (1×23) + (1×22) + (1×21) + (1×20) = 810 + 410 + 210 + 110 = 1510 Powers of 10 Powers of 2
Convert Binary to Decimal 101101012 (1×27) + (0×26) + (1×25) + (1×24) + (0×23) + (1×22) + (0×21) + (1×20) = 128 + 0 + 32 + 16 + 0 + 4 + 0 + 1 = 18110
Convert Decimal to Binary:“Successive Division by Two” Example Decimal Number: 29 1 0 1 1 1 Binary Result: 1 1 1 0 1