21
Numeration Systems Introduction to Binary, Octal, and Hexadecimal

Numeration Systems

  • Upload
    caia

  • View
    30

  • Download
    0

Embed Size (px)

DESCRIPTION

Numeration Systems. Introduction to Binary, Octal, and Hexadecimal. Before There Were Numbers. Quantities represented by metaphors Analog Easy to Understand Comparisons to Real World Imprecise – can’t really count. http://www.allaboutcircuits.com/vol_4/chpt_1/1.html. Let’s Count to 10. - PowerPoint PPT Presentation

Citation preview

Page 1: Numeration Systems

Numeration Systems

Introduction to Binary, Octal, and Hexadecimal

Page 2: Numeration Systems

Before There Were Numbers• Quantities

represented by metaphors

• Analog• Easy to Understand• Comparisons to

Real World• Imprecise – can’t

really counthttp://www.allaboutcircuits.com/vol_4/chpt_1/1.html

Page 3: Numeration Systems

Let’s Count to 10

Words Counting Lines

Roman Numerals Decimal

Zero ? ? 0One | I 1Two || II 2Three ||| III 3Four |||| IV 4Five ||||| V 5Six ||||| | VI 6Seven ||||| || VII 7Eight ||||| ||| VIII 8Nine ||||| |||| IX 9Ten ||||| ||||| X 10

Numbers are digital: finite, precise and countable.

Page 4: Numeration Systems

Why we use numbers• Ancient number systems are pretty bad• Decimal System is place-weighted• Tens place, Hundreds place, etc.• Or, if you want to use math notationsThousand

sHundred

sTens Ones . Tenths Hundredths

103 102 101 100 . 10-1 10-2

Page 5: Numeration Systems

How the decimal system works

• Let’s take a number: 2074

• Final Value for each column: Place value times digit value

• Final numerical value: add the column values (2000 + 70 + 4)

Digits 2 0 7 4Place Value 103 (1000) 102 (100) 101 (10) 100 (1)Column Value 2 x 103 0 x 102 7 x 101 4 x 100

Page 6: Numeration Systems

About digits• For decimal, we need ten digits: 0 – 9• It because it’s a Base 10 system• each “place” needs 10 possible

values (including 0)

Page 7: Numeration Systems

Binary Number SystemPlace-weighted, like Decimal, but Base 2Bit = binary digitGroup of 8 bits is a byte210 (1024) bytes = 1 Kilobyte (KB)210 KB = 1 Megabyte (MB)

Sixty-Fours

Thirty-Twos

Sixteens Eights Fours Twos Ones

26 25 24 23 22 21 20

Place values are powers of 2 instead of

10

Decision of early computer

makers.

Page 8: Numeration Systems

Why Binary?• Modern Computers store information as

bits, and perform all their calculations on binary numbers.

• Modern computers are basically millions of tiny switches (called transistors) that can be on or off (1 or 0)

• They work most efficiently in binary• Less errors

Page 9: Numeration Systems

Let’s Count AgainWords Counting

LinesRoman Numerals

Decimal Binary

Zero ? ? 0 0One | I 1 1Two || II 2 10Three ||| III 3 11Four |||| IV 4 100Five ||||| V 5 101Six ||||| | VI 6 110Seven ||||| || VII 7 111Eight ||||| ||| VIII 8 1000Nine ||||| |||| IX 9 1001Ten ||||| ||||| X 10 1010

Binary needs more “places” torepresent the same numbers

Page 10: Numeration Systems

Binary to Decimal conversions

• Multiply each bit by its place value and add

• Example: 1001Binary 1 0 0 1Place Values 8 4 2 1

Column Values

8 0 0 18 + 1 = 9

Page 11: Numeration Systems

Octal and Hexadecimal• Base 8 (Octal) and Base 16 (Hex)• Hex – need 16 digits in one “place”• Hex Digits: 0123456789ABCDEF• 1 Hex Digit = 4 bits• It works because 16 is a powers of 2• Hex is most used, since a byte is

represented nicely by 2 Hex Digits

Page 12: Numeration Systems

Notes on Notation• Octal numbers use the digits 0-7• Octal numbers are preceded by oct• Hex Digits use CAPITAL LETTERS A-F• If we mix hex and decimal, hex numbers

will have a lower-case ‘h’ after them• Examples: 29h, A7h, 10h• Generic math notation uses subscripts:• 11010112, 7338, AE16

Page 13: Numeration Systems

Hex Decimal• Base 16 place values• Let’s try 1B9

• 1 x 256 + 11 x 16 + 9 = 441

Hex Number

1 B(11) 9

Place Values

162 (256) 161 (16) 160 (1)

Page 14: Numeration Systems

Hex Digit Binary ChartHex Digit Binary Hex Digit Binary

0 0000 8 10001 0001 9 10012 0010 A 10103 0011 B 10114 0100 C 11005 0101 D 11016 0110 E 11107 0111 F 1111

Notice that one Hex digit can represent every possible binary number for 4 bits. (Decimal numbers 0 – 15)

Page 15: Numeration Systems

Hex to Binary is easy!• Convert single hex digit to binary

using the chart or by counting• String the binary digits in order• Example: F5

• Answer: 11110101

F 51111 0101

Don’t forget that zero!

Page 16: Numeration Systems

Binary to Hex is easy!• Reverse what we did for Hex to

Binary• Divide the Binary number in groups

of four bits from right to left• Example: 1011101

0101 11015 D

Extra zero added on end

Page 17: Numeration Systems

Decimal-To Conversions• Trial and Fit method:• Keep finding the highest digit that can

“fit” into the decimal number, then subtract from the original #

• Prob: Convert 87 into Binary:We’d start by noticing that a ‘1’ in the 128s place is too muchTry a ‘1’ in the 64s place to get a total of 64Try a 1 in the 32s place gives us a total of 96

That’s >87 so it must be a 0Trying a 1 in the 16s place gives a total of 801 in the 8s place gives 88. It’s too much, so 0

1 in 4s place, 1 in 2s place,1 in 1s place, you get 87

View this slide in a slide show to see the

animation

Page 18: Numeration Systems

Decimal-To Conversions• Is there an easier way?• Yes! Division Remainder Method• Take your number, divide by 2 for binary,

8 for octal, 16 for hex• The Remainder of the division is a digit in

your answer• Repeat process using the Quotient, until

the Quotient is zero• Put the remainders together backwards

for your answer

Page 19: Numeration Systems

Examples• 137 Binary137 ÷ 2 = 68 r168 ÷ 2 = 34 r034 ÷ 2 = 17 r017 ÷ 2 = 8 r18 ÷ 2 = 4 r04 ÷ 2 = 2 r02 ÷ 2 = 1 r01 ÷ 2 = 0 r1

1 0 0 0 1 0 0 1

The LAST remainder you get becomes the FIRST bit of your answer.

Page 20: Numeration Systems

Example• 137Hex137 ÷ 16 = 8 r98 ÷ 16 = 0 r8

8 9

Watch out! Hex numbers can look like decimal numbers. In this case, 137 decimal is equal to 89 hex. If this idea confuses you, just remember that the place values are different. In this example, the ‘8’ from the answer is in the “sixteens” place, NOT the ‘tens’ place like it would be normally.

Page 21: Numeration Systems

Why Hex?• You’ve seen that the Hex Binary

conversions are very simple.• Hex is often used as shorthand for

binary, since two hex digits easily represents a byte.

• Computer Forensics – when you look at “raw” computer data, it’s usually Hex.

• Hex-editing lets you “hack” and cheat at video games.