12
ECE 2110: Introduction to Digital Systems Number Systems: conversions

ECE 2110: Introduction to Digital Systems

Embed Size (px)

DESCRIPTION

ECE 2110: Introduction to Digital Systems. Number Systems: conversions. Previous class Summary. Positional number systems Common Base 2, 8, 10, 16 Others !. Hex (base 16) to Binary Conversion. - PowerPoint PPT Presentation

Citation preview

Page 1: ECE 2110: Introduction to Digital Systems

ECE 2110: Introduction to Digital Systems

Number Systems: conversions

Page 2: ECE 2110: Introduction to Digital Systems

2

Previous class Summary

Positional number systemsCommon Base 2, 8, 10, 16Others !

Page 3: ECE 2110: Introduction to Digital Systems

3

Hex (base 16) to Binary Conversion

Each Hex digit represents 4 bits. To convert a Hex number to Binary, simply convert each Hex digit to its four bit value.

Hex Digits to binary (cont):916 = 10012

A16 = 10102

B16 = 10112

C16 = 11002

D16 = 11012

E16 = 11102

F16 = 11112

Hex Digits to binary:016 = 00002

116 = 00012

216 = 00102

316 = 00112

416 = 01002

516 = 01012

616 = 01102

716 = 01112

816 = 10002

Page 4: ECE 2110: Introduction to Digital Systems

4

Hex to Binary, Binary to Hex

A2F16 = 1010 0010 11112

34516 = 0011 0100 01012

Binary to Hex is just the opposite, create groups of 4 bits starting with least significant bits. If last group does not have 4 bits, then pad with zeros for unsigned numbers.

10100012 = 0101 00012 = 5116

Padded with a zero

Page 5: ECE 2110: Introduction to Digital Systems

5

Octal to Binary, Binary to Octal

3458 = 011 100 1012

Binary to Octal is just the opposite, create groups of 3 bits starting with least significant bits. If last group does not have 3 bits, then pad with zeros for unsigned numbers.

10100012 = 001 010 0012 = 1218

Padded with a zero

Page 6: ECE 2110: Introduction to Digital Systems

6

Conversion of Any Base to Decimal

Converting from ANY base to decimal is done by multiplying each digit by its weight and summing.

1011.112 = 1x23 + 0x22 + 1x21 + 1x20 + 1x2-1 + 1x2-2

= 8 + 0 + 2 + 1 + 0.5 + 0.25 = 11.75

Binary to Decimal

Hex to Decimal

A2F16 = 10x162 + 2x161 + 15x160 = 10 x 256 + 2 x 16 + 15 x 1 = 2560 + 32 + 15 = 2607

Page 7: ECE 2110: Introduction to Digital Systems

7

A Trick!

If faced with a large binary number that has to be converted to decimal, I first convert the binary number to HEX, then convert the HEX to decimal. Less work!

1101111100112 = 1101 1111 00112

= D16 F16 316

= 13 x 162 + 15 x 161 + 3x160

= 13 x 256 + 15 x 16 + 3 x 1 = 3328 + 240 + 3 = 357110

Of course, you can also use the binary, hex conversion feature on your calculator. Calculators won’t be allowed on the first test, though…...

Page 8: ECE 2110: Introduction to Digital Systems

8

Conversion of Decimal Integer To ANY Base

Divide Number N by base R until quotient is 0.

Remainder at EACH step is a digit in base R, from Least Significant digit to Most significant digit.

Page 9: ECE 2110: Introduction to Digital Systems

9

Example

Convert 53 to binary

53/2 = 26, rem = 1 26/2 = 13, rem = 0 13/2 = 6 , rem = 1 6 /2 = 3, rem = 0 3/2 = 1, rem = 1 1/2 = 0, rem = 1

5310 = 1101012

= 1x25 + 1x24 + 0x23 + 1x22 + 0x21 + 1x20

= 32 + 16 + 0 + 4 + 0 + 1 = 53

Least Significant Digit

Most Significant Digit

Page 10: ECE 2110: Introduction to Digital Systems

10

More Conversions

Convert 53 to Hex

53/16 = 3, rem = 5 3 /16 = 0 , rem = 3 5310 = 3516

= 3 x 161 + 5 x 160

= 48 + 5 = 53

9710=??? 16

Page 11: ECE 2110: Introduction to Digital Systems

11

Binary Numbers Again

Recall that N binary digits (N bits) can represent unsigned integers from 0 to 2N-1.

4 bits = 0 to 158 bits = 0 to 25516 bits = 0 to 65535

Besides simply representation, we would like to also do arithmetic operations on numbers in binary form. Principle operations are addition and subtraction.

Page 12: ECE 2110: Introduction to Digital Systems

12

Next…

Additions/subtractions