Sei sulla pagina 1di 4

10/2/17

Counting Systems Overflow


• What happens when we
• Used to represent quantities reach 9?

• We’re out of distinct digits


to use
• We normally count in Base 10 (decimal)
• This causes us to overflow to
• Ten digits: 0 1 2 3 4 5 6 7 8 9 a new position
• There’s no special significance to
• 10, 100, 1000...
these symbols, though
• “10” = “all fingers extended”

Sums of Powers
Positional Number
System
• Each position indicates some power of
the base
• ex. ones, tens, hundreds, thousands,
etc.
• We can describe a number as the sum
of various powers of the base
• Ex. 123 = 1x102 + 2x101 + 3x100

1
10/2/17

Counting in Binary Same Value, Different Base


Base 10 Base 8 Base 2 Base 10 Base 8 Base 2
• Binary (base 2) only has two digits 0 0 0 8 10 1000
• A “binary digit” is also called a “bit” 1 1 1 9 11 1001
2 2 10 10 12 1010
• Bits “roll over” more quickly than they 3 3 11 11 13 1011
do in base 10 (or another base) 4 4 100 12 14 1100
5 5 101 13 15 1101
• 0, 1, 10, 11, 100, 101, 110, 111, 1000... 6 6 110 14 16 1110
7 7 111 15 17 1111

Longer, Not Larger From Any Base to Decimal


• Changing the base doesn’t change the • Under each digit, write
the power of the base
magnitude (value) of a number that goes with that 111010 (Base 2) to Base 10
position
• The representation for a number gets longer 1 1 1 0 1 0
as the base decreases • Multiply each digit by x x x x x x
its power of the base 32 16 8 4 2 1
• There are fewer possible symbols (digits)
available for each position • Add up all of these 32 + 16 + 8 + 0 + 2 + 0
products
= 58 (base 10)
• This means there are fewer possible
• The sum is equal to the
combinations of symbols for a certain length decimal (base 10) value

2
10/2/17

From Decimal to Any Base An Example


• Repeatedly divide the • Convert 12 (decimal) to binary (base 2):
original number by the base 0
47 (base 10) to Base 5:
• 12 / 2 is 6, with remainder 0:
• Set aside the remainder of
each division • 6 / 2 is 3, with remainder 0: 00
47 ÷ 5 = 9 remainder 2
• Use the quotient for the 9 ÷ 5 = 1 remainder 4 • 3 / 2 is 1, with remainder 1: 100
next round of division 1 ÷ 5 = 0 remainder 1
• 1 / 2 is 0, with remainder 1: 1100
• When the quotient reaches 0, Answer: 142 (base 5)
write down all of the • Our quotient is 0, so we’re done.
remainders in order from last • The final answer (in base 2) is 1100
to first. This value is your
answer.

Hexadecimal
• Binary numbers are very long, and hard
for humans to remember
• If we group digits (bits) together, we
The Joy of Hex have less to remember
• There are 16 possible 4-bit combinations
• This is base 16 (hexadecimal)
• We use A-F for the extra digits

3
10/2/17

More Online Humor Hexadecimal Example


• Convert 10011100 to hexadecimal
• Group the number into 4-bit groups,
working from right to left

<Chipper> Hexadecimal counting systems are awesome! • 1001 1100


<Chipper> On a scale from 1 to 10, I give them an E
— seen on bash.org • 1001 = 9
• 1100 = 12 = C
• 10011100 (binary) is 9C
(hexadecimal)

Another Geek Joke


• 3x12 = 36
• 2x12 = 24
• 1x12 = 12
• 0x12 = 18

• Explanation: “0x” is a prefix that means a


Hexadecimal in Real Life value is in base 16. “3x12” means “multiply”,
but “0x12” means the hexadecimal value “12”

Potrebbero piacerti anche