L04-Number System Conversion
L04-Number System Conversion
Example:
Convert the decimal number 610 into its binary equivalent.
3
2 6 r 0 Least Significant Bit
1
2 3 r 1 610 = 1102
0
2 1 r 1 Most Significant Bit
2
Dec → Binary : Example #1
Example:
Convert the decimal number 2610 into its binary equivalent.
3
Dec → Binary : Example #1
Example:
Convert the decimal number 2610 into its binary equivalent.
Solution:
13
2 26 r 0 LSB
6
2 13 r 1
3
2 6 r 0 2610 = 110102
1
2 3 r 1
0
2 1 r 1 MSB
4
Dec → Binary : Example #2
Example:
Convert the decimal number 4110 into its binary equivalent.
5
Dec → Binary : Example #2
Example:
Convert the decimal number 4110 into its binary equivalent.
Solution:
20
2 41 r 1 LSB
10
2 20 r 0
5
2 10 r 0 4110 = 1010012
2
2 5 r 1
1
2 2 r 0
0
2 1 r 1 MSB
6
Dec → Binary : More Examples
a) 1310 = ?
b) 2210 = ?
c) 4310 = ?
d) 15810 = ?
7
Dec → Binary : More Examples
a) 1310 = ? 11012
b) 2210 = ? 101102
c) 4310 = ? 1010112
d) 15810 = ? 100111102
8
Binary ‒to‒ Decimal Process
The Process : Weighted Multiplication
a) Multiply each bit of the Binary Number by it corresponding bit-
weighting factor (i.e. Bit-0→20=1; Bit-1→21=2; Bit-2→22=4; etc).
b) Sum up all the products in step (a) to get the Decimal Number.
Example:
Convert the decimal number 01102 into its decimal equivalent.
0 1 1 0
23 22 21 20
Bit-Weighting 0110 2 = 6 10
8 4 2 1 Factors
0 + 4 + 2 + 0 = 610
9
Binary → Dec : Example #1
Example:
Convert the binary number 100102 into its decimal equivalent.
10
Binary → Dec : Example #1
Example:
Convert the binary number 100102 into its decimal equivalent.
Solution:
1 0 0 1 0
24 23 22 21 20
16 8 4 2 1
16 + 0 + 0 + 2 + 0 = 1810
\100102 = 1810
11
Binary → Dec : Example #2
Example:
Convert the binary number 01101012 into its decimal
equivalent.
12
Binary → Dec : Example #2
Example:
Convert the binary number 01101012 into its decimal
equivalent.
Solution:
0 1 1 0 1 0 1
26 25 24 23 22 21 20
64 32 16 8 4 2 1
0 + 32 + 16 + 0 + 4 + 0 + 1 = 5310
\01101012 = 5310
13
Binary → Dec : More Examples
a) 0110 2 = ?
b) 11010 2 = ?
c) 0110101 2 = ?
d) 11010011 2 = ?
14
Binary → Dec : More Examples
a) 0110 2 = ? 6 10
b) 11010 2 = ? 26 10
c) 0110101 2 = ? 53 10
d) 11010011 2 = ? 211 10
15
Summary & Review
Base10 Successive
Division
Base2
DECIMAL BINARY
a) Divide the Decimal Number by 2; the remainder is the LSB of Binary
Number .
b) If the Quotient Zero, the conversion is complete; else repeat step (a) using
the Quotient as the Decimal Number. The new remainder is the next most
significant bit of the Binary Number.
Base2 Weighted
Multiplication
Base10
BINARY DECIMAL
a) Multiply each bit of the Binary Number by it corresponding bit-weighting
factor (i.e. Bit-0→20=1; Bit-1→21=2; Bit-2→22=4; etc).
b) Sum up all the products in step (a) to get the Decimal Number.
16
Converting numbers from other bases to their
decimal equivalents
• Binary 1001 (so r=2) : • Hexadecimal 12AC (so r=16):
• D = 1x20+0x21+0x22+1x23 • D = Cx160+Ax161+2x162+1x163
= 1+0+0+8 = 12+160+512+4096
=9 = 4780
• Octal 1767 (so r=8) :
• (A represents a decimal 10 and C
• D = 7x8 +6x8 +7x8 +1x8
0 1 2 3
represents a decimal 12)
= 7+48+448+512
= 1015
12/14/2023 18
Binary → hex/decimal/octal conversion
• Conversion from binary to octal/hex
• Binary: 10011110001
• Octal: 10 | 011 | 110 | 001=23618
• Hex: 100 | 1111 | 0001=4F116
1011 1011
+ 1010 – 0110
10101 0101
Number systems
• How do we write negative binary numbers?
• Historically: 3 approaches
• Sign-and-magnitude
• Ones-complement
• Twos-complement
12/14/2023 32
Number Overflow
• 100000010 in our scheme represents 126, not +130. If, however, we
were not representing negative numbers, the result would be correct.
12/14/2023 33
Code for Letters and Symbols
• Computers use a standard binary code to represents letters of the alphabet,
numerals, punctuation marks and other special characters.
• The code is called ASCII (pronounced “askey”) which stands for “American
Standard Code for Information Interchange.”
• There are 256 code combinations.
12/14/2023 34
Sources
• [1] http://en.wikipedia.org/wiki/Numeral_systems
• [2] http://www.mathsisfun.com/definitions/base-numbers-.html
• [3] http://atrevida.comprenica.com/atrtut01.html
• [4] http://www.mindspring.com/~jimvb/binary.htm
12/14/2023 35