Professional Documents
Culture Documents
Lecture 2
Fall 2017
Mohamed Elgalhud
Number Systems Representation - General
Form
A number with radix r is represented by a string of
digits:
An - 1An - 2 … A1A0 . A- 1 A- 2 … A- m + 1 A- m
in which 0 Ai < r and . is the radix point.
The string of digits represents the power series:
Number = ( i=n-1
Ai r )+(
i
j=-1
Aj r) j
i=0 j=-m
(Integer Portion) + (Fraction Portion)
(11010.11)2 = (?) 10
(127.4)8= (?) 10
(B65F)16 =(?) 10
2 • 256 + 10 • 16 + 12 • 1 = 684 9
10
9
a
11 b
12 c
163 162 161 160 13 d
4096 256 16 1 14 e
8 9/26/2017
15 f
Reference: Lecture Notes of Eng.Yusra Maatog
Conversion from Decimal to other bases
To Convert the Integral Part:
Repeatedly divide the number by the new radix and save the
remainders. The digits for the new radix are the remainders in
reverse order of their computation. Keep dividing until the quotient
becomes zero. If the new radix is > 10 (r=16), then convert all
remainders > 10 to digits A, B, …
(0.6875)10 = (0.1011)2
128 64 32 16 8 4 2 1
19 9/26/2017
Reference: Lecture Notes of Eng.Yusra Maatog
Conversion Between Bases
To convert from one base to another:
1) Convert the Integer Part
2) Convert the Fraction Part
3) Join the two results with a radix point
20 9/26/2017
Reference: Lecture Notes of Eng.Yusra Maatog
Octal to Binary
Restate the octal as three binary digits starting at the
radix point and going both ways.
Example:
21 9/26/2017
Reference: Lecture Notes of Eng.Yusra Maatog
Binary to Octal
Group the binary digits into three bit groups starting at
the radix point and going both ways.
Convert each group of three bits to an octal digit.
Example
(100111100101)2 = (4745)8
22 9/26/2017
Reference: Lecture Notes of Eng.Yusra Maatog
Binary to Octal
Group the binary digits into three bit groups starting at
the radix point and going both ways.
Convert each group of three bits to an octal digit.
Example
(100111100101)2 = (4745)8
23 9/26/2017
Reference: Lecture Notes of Eng.Yusra Maatog
Octal (Hex) to Binary and Back
Hexadecimal to Binary:
Restate the hexadecimal as four binary digits starting at the radix
point and going both ways.
Binary to Hexadecimal
Group the binary digits into four bit groups starting at the radix
point and going both ways
Convert each group of four bits to an hexadecimal digit.
(100111100101)2 = (9E5)16
(10110001101011.11110010)2 =( ?)16
24 9/26/2017
Reference: Lecture Notes of Eng.Yusra Maatog
Bin Hex
0000 0
Hex to Binary 0001 1
0010 2
Hex to Binary – just convert digits
0011 3
0100 4
0101 5
0x2ac 0110
0111
6
7
1000 8
1001 9
0010 1010 1100 1010 a
1011 b
0x2ac = 001010101100
1100 c
1101 d
1110 e
1111 f
25 9/26/2017
Reference: Lecture Notes of Eng.Yusra Maatog
Bin Hex
0000 0
Binary to Hex
0001 1
0010 2
Just convert groups of 4 bits 0011 3
0100 4
101001101111011 0101 5
0110 6
26 9/26/2017
Reference: Lecture Notes of Eng.Yusra Maatog
Octal to Hexadecimal via Binary
Convert octal to binary.
Use groups of four bits and convert as the previous example
to hexadecimal digits.
Example: Octal to Binary to Hexadecimal
(6 3 5 . 1 7)8
110 011 101 001 111
110011101.001111
(0001)(1001)(1101).(0011)(1100)
1 9 D . 3 C (635.17) = 0x19D.3C
The same way can be used to convert Hexadecimal to Octal
i.e. Hexadecimal Binary Octal
27 9/26/2017
Reference: Lecture Notes of Eng.Yusra Maatog
Summary
Conversion between Binary/Octal/Hex
1. Nice simple ways to convert between these three number
systems, since all are a power of 2
28 9/26/2017
Reference: Lecture Notes of Eng.Yusra Maatog