Chapter 3
Chapter 3
Chapter 3
Page 1
Chapter Three
Value 128 64 32 16 8 4 2 1
Weight 27 26 25 24 23 22 21 20
Page 2
Chapter Three
The hexadecimal system is based on the binary system using a Nibble or 4 bit boundary. The
hexadecimal number system
- uses base 16
- Includes only the digits 0 through 9 and the letters A, B, C, D, E, and F for the numbers
starting from 10 to 15 respectively.
Value 268435456 16777216 1048576 65536 4096 256 16 1
Weight 167 166 165 164 163 162 161 160
Position VIII VII VI V IV III II I
CONVERSION SYSTEM
A brief summary on conversion from one base to another base
No From base To base Method
1 2 10 Expand binary number in powers of 2
2 10 2 Divide the decimal number by 2 until the reminder becomes zero or
impossible to be divided by 2.
3 2 8 Group 3 binary digits together (preferable) but you can go from
2108
4 8 2 Each Octal digit is converted to 3 binary digits (preferable and simplest
method) but you can go from 8102
5 2 16 Group 4 binary digits together (preferable and simplest method) but you
can go from 21016
6 16 2 Each hexadecimal digit is converted to 4 binary digits(preferable and
simplest method) but you can go from 16102
7 8 10 Go from 8210 or Expand the octal number in power of 8.
8 10 8 Go from 1028 or divide the decimal number by 8 until the quotient
becomes zero.
9 16 10 Go from 16210 or Expand the hex-decimal number in power of 16.
1 10 16 Go from 10216 or divide the decimal number by 16 until the
0 quotient becomes zero.
1 8 16 Go from 8216 (preferable and simplest method) but you can go
1 from 81016
1 16 8 Go from 1628 (preferable and simplest method) but you can go
2 from 16108
Page 3
Chapter Three
4 3 2 1 0
11001 = 1x2 + 1x2 +0x2 +0x2 +1x2 =
16+8+1= 25 (integer part)
0101=0x2-1+1x2-2+0x2-3+1x2-4=
0+¼+0+1/16 = 0.3125 (fraction part)
11001.0101 = (25.3125)10
Convert (1000.1)2 to decimal
(1000)2= (1+23 +0+0+0) 10= (8)10 (integer part)
0.1= 1x2-1=½ = (0.5) 10 (fractional part)
(1000.1)2 = (8.5)10 (after combination of both results of integral & fractional part)
Ex 2. Convert 5610 to binary
(56)10 = (111000)2
Ex 3. Convert (1001001)2 to octal
1001001=001 001 001
= (111)8
Convert 101101001 to octal
101101001=101 101 001
5 5 1
= (551)8
Exercise: - Covert (1010.0111)2 to its equivalent octal number
Ex 4. Convert (675)8 to binary
68 = (110) 2 78= (111) 2 58= (101) 2
Therefore, (675)8 = (110111101)2
Convert 2318 to binary
2318 = (010 011 001) 2
=(10011001)2
Ex 5. Convert 111100100 to hexadecimal
Page 4
Chapter Three
416=01002
23416 = (1000110100)2
Convert 2AC16 to binary
2AC16 = (0010 1010 1100) 2
= (1010101100)2
Ex 7. Convert (234)8 to decimal
Ans. = (156)10
Convert (101)8 to decimal
Ans. =(65)10
Ex 8. Convert 7810 to base 8 (Octal)
7810=1168
Ex 9. Convert (A1B) 16 to decimal
Ans. = (2587)10
Convert (101)16 to decimal
Ans. =(257)10
Ex 10. Convert 3010 to base 16 (hex-decimal)
3010=(1E)16
Convert (16)10 to base 16 (hexadecimal)
1610=(10)16
Ex.11. Convert 2358 to hexadecimal
2388=010 011 101
=0000 1001 1101
=0 9 13=D
=(9D)16
Ex.12. Convert 1A16 to Octal
116=00012
A16=10102
= (000 011 010) 2
(0 3 2)8
=(32)8
Page 5
Chapter Three
4. (15)10= (?)2 Ans.(1111)2
5. (65.2)10= (?)2 Ans. (1000001.0011...)2
6. (100.011)10= (?)2 Ans.(1100100.00000001…)2
7. (59.99)10= (?)2 Ans.(111011.111)2
8. (40.34)2= (?)2 Ans.(101000.0101)2
B. binary to decimal conversion
9. (110010)2= (?)10 Ans.(50)10
10. (11101101.10101)2= (?)10 Ans.(237.65625)10
11. (11)2= (?)10 Ans.(3)10
12. (1111)2= (?)10 Ans. (15)10
Binary Arithmetic
Binary numbers can be added, subtracted, multiplied and divided like natural numbers-decimal
numbers in which everybody uses them for day-to-day activities. Let’s see how binary arithmetic is
performed.
1. Binary addition
Rules
0+1=1
1+1=0 with carry 1 to the next digit
1+1+1=1 with carry 1 to the next digit
1+1+1+1=0 with carry 2 to the next digit
E.g. Add (10111)2 and (110101)2
Solution
110101
+10111
1001100
2. Binary subtraction
Rules
1-1=0
1-0=1
0-1=1 borrows 1 from the highest digit
E.g. Subtract (10101)2 from (101110)2
Solution
101110
-10101
11001
Page 6
Chapter Three
** Binary subtraction can be also done using complements.
E.g. (1110-10101)2= (?)2
Solution
Rule: A-B=A+ (-B), where B is 2’s complement
2’s complement=1’s complement + 1
(10101)2 1’s complemenent = (01010)2 and its 2’s complemenent= (01011)2.
Then, apply the rule i.e. (1110 + 01011)2= (1110-1011)2= (11001)2
3. Binary multiplication
Rules
1x1=1
0x1=0
E.g. 1. Multiply (1111)2 by (111)2
Solution
1111
X 111
1111
1111
1111
(1101001)2
Page 7
Chapter Three
Rules
This rule works for a number in which the remainder becomes zero. It may work for non-zero
remainder numbers with some modifications.
a) Divide the dividend by the divisor until the remainder becomes zero or less than the divisor
(impossible to be divided).
b) When you take two or three etc numbers of a dividend to add on the remainder part, you have
to add one zero (0) or two (00) etc on the quotient respectively.
c) When you divide a number having fractional part, don’t worry about the fraction. Divide the
number as it is an integer number. But after you complete the division, count the number of fractional
digits from left to right to both the dividend (D) and divisor (Df). Then the number of fractional parts of
the quotient (Qf) from left to right is equal to the difference between of D & Df.
d) Checking the result
Dividend=quotient * divisor + remainder
E.g.1. Divide (100001)2 by (11)2
Solution
Checking: 100001=11x1011 + 0
100001=100001
E.g. 2. Divide (1011.01)2 by (10.1)2
Solution
Checking
1011.01=100.1x10.1 + 0
1011.01=1011.01
Note: If the difference between D & Df is negative, add zero(s) as many as the number of the
difference on the right side of the quotient. Let’s see it with an example.
Page 8
Chapter Three
E.g.3. Divide (101101)2 by (10.1)2
Solution
CODING METHODS
- It is possible to represent any of the character in our language in a way as a series of
electrical switches in arranged manner.
- These switch arrangements can therefore be coded as a series of an equivalent arrangements
of bits.
- There are different coding systems that convert one or more character sets into computer
codes. Some of them are the followings :
BCD (6-bits)
- Stands for Binary Coded Decimal
- It uses 6-bits to code a Character
BCD coding Examples
EBCDIC
- Pronounced as “Eb-see-dick” and stands for Extended Binary Coded Decimal Interchange
Code.
Page 9
Chapter Three
- It is an 8-bit coding scheme; (00000000 – 11111111)
- It accommodates to code 28 or 256 different characters
- It is a standard coding scheme for the large computers.
Coding Examples
EBCDIC
Character Zone Digit
a 1000 0001
b 1000 0010
A 1100 0001
B 1100 0010
0 1111 0000
9 1111 1001
ASCII-7
- ASCII stands for American Standard Code for Information Interchange
- Used widely before the introduction of ASCII-8 (the Extended ASCII)
- Uses 7 bits to represent a character;
- With the seven bits, 27 ( or 128) different characters can be coded (0000000-1111111)
- It has a zone and digit bits positions
ASCII-7 coding examples:
Page 10
Chapter Three
Coding Examples
Binary representation in ASCII
Character Zone Digit
a 0110 0001
b 0110 0010
A 0100 0001
B 0100 0010
? 0011 1111
+ 0010 1011
1 0011 0001
2 0011 0010
3 0011 0011
Page 11
Chapter Three
- The commonly used byte contains 8 bits; or also contains exactly two nibbles.
- Since each bit has two states and there are 8 bits in a byte, the total amount of data that can
be represented is 28 or 256 possible combinations.
- Each byte can represent a character (a character is either a letter, a number or a special
symbol such as +,-,?,*, $, etc.
- A byte is then used as a unit of measurement in the computer memory, processing unit,
external storage and during communication.
- If the computer memory is 524288 byte, this is expressed in short by saying 512KB, where
KB stands for kilobyte.
Key: 1 Kilobyte (1KB) is 210 or 1024 bytes
1 Megabyte (MB) is 220 bytes or 210 kilobytes
1 Gigabyte (GB) is 230 bytes or 220 kilobytes or 210 megabytes
WORD
- Word refers the number of bits that a computer process at a time or a transmission media
transmits at a time.
- Although bytes can store or transmit information, the process can even be faster if more than
one byte is processed at a once.
- A combination of bytes, then form a “word”.
- A word can contain one, two, three or four bytes based on the capacity of the computer.. So
we may have double word, triple and more.
- We say that a computer is an 8-bit, a 16 bit, a 32 bit or a 64 bit computer to indicate that the
amount of data it can process at a time. Word length is usually given in bits. A word also contains either
16 bits or two bytes.
- The large the word length a computer has the more powerful and faster it is.
Page 12
Chapter Three
Page 13