Transcript Conversions
ECE 2110: Introduction to Digital
Systems
Number Systems: conversions
Previous class Summary
Positional number systems
Base 2, 8, 10, 16
Conversions:
Binary <---->Hex
2
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
3
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
4
Conversion of Any Base to Decimal
Converting from ANY base to decimal is done by multiplying
each digit by its weight and summing.
Binary to Decimal
1011.112 = 1x23 + 0x22 + 1x21 + 1x20 + 1x2-1 + 1x2-2
= 8
+ 0 + 2 + 1 + 0.5 + 0.25
= 11.75
Hex to Decimal
A2F16 = 10x162 + 2x161 + 15x160
= 10 x 256
+ 2 x 16 + 15 x 1
= 2560 + 32 + 15 = 2607
5
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,
6
though…...
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.
7
Example
Convert 53 to binary
53/2 =
26/2 =
13/2 =
6 /2 =
3/2 =
1/2 =
26,
13,
6 ,
3,
1,
0,
rem = 1
rem = 0
rem = 1
rem = 0
rem = 1
rem = 1
Least Significant Digit
Most Significant Digit
5310 = 1101012
= 1x25 + 1x24 + 0x23 + 1x22 + 0x21 + 1x20
= 32 + 16 + 0 + 4 + 0 + 1 = 53
8
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
9
Binary Numbers Again
Recall that N binary digits (N bits) can represent unsigned
integers from 0 to 2N-1.
4 bits = 0 to 15
8 bits = 0 to 255
16 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.
10
Next…
Additions/subtractions
11