Number System and Binary
Number System and Binary
ARITHMETIC
Introduction to Number System
Definition: Number system is the way to represent a number in different forms.
1. Binary Number System: It is the number system with base value 2 means it has only two
digits to represent the data. The digits are (0, 1). E.g. 00,01,10,11,100….
2. Decimal Number System: It is the number system with base value 10 means it has 10-
digits to represent the data. The digits are(0-9). Eg. 0,1,2,3,4,5,6 ………
3. Octal Number System: It is the number system with base value 8 means it has 8 digits to
represent the data. The digits are ( 0-7).
4. Hexadecimal Number System : It is the number system with base value 16 means it has
16 digits to represent the data. The digits are (0-15). Eg. 0,1,2,3…….,9,A,B,C,D,E,F
1 byte = 8-bits
0 Start at 0
1 Then 1
??? Then no other symbol
Page 43 of 199
So we count in the same way as using decimal number system. For example:
Decimal number system start at 0 and then 1,2,3,4,5,6,7,8,9… now what after nine repeat the
no in combination such as start at 0 again the add 1 to the left of 0 resultant 10 , 11 ,12… so on.
100, 1000 etc.
If no, Just look at the power values : 20, 21, 22, 23, 24…….2n
2 0= 1
2 1= 2
2 3= 8
Page 44 of 199
24=16 so on…..
Hmmm…..again what about 3? If I will add 2+1 =3 so there for 1 is assigned in front of the
power of 20 and 21.
Still not get : Ok read this,
Decimal
Well how do we count in Decimal? 0 Start at 0
... Count 1,2,3,4,5,6,7,8, and then...
9 This is the last digit in Decimal
10 So we start back at 0 again, but add 1 on the left
Binary
0 Start at 0
• 1 Then 1
•• 10 Now start back at 0 again, but add 1 on the left
••• 11 1 more
•••• ??? But NOW what ... ?
In this system the base is eight. The allowed digits are 0 – 7 where as 8 is not allowed.
Typical number
N= (4526.23)8
Page 45 of 199
The hexadecimal
A typical number
N = (A1F.1C)16
Step-1: Divide the Number by 2 (as 2 is the base of the binary number system).
Step-5: Start from bottom, read the sequence of remainders upwards to the top.
This number system has a base value 16. We can use (0-15) decimal numbers to represent
hexadecimal numbers. It uses 16 distinct numbers to represent the values.
Page 46 of 199
Decimal numbers Binary Number Hexadecimal Number
0 00 0
1 01 1
2 10 2
3 11 3
4 100 4
5 101 5
6 110 6
7 111 7
8 1000 8
9 1001 9
10 1010 A
11 1011 B
12 1100 C
13 1101 D
14 1110 E
15 1111 F
ASCII (American Standard Code Interchange Information) Code: ASCII is a character set that is
used to interchange information to binary and from binary to decimal. ASCII is a 8-bit character
containing 256 characters.
Unicode: Unicode is a character set that is used to interchange information to binary language
and from binary to decimal language. The latest version of Unicode is Unicode 6.0. It is a
computing industry standard encoding scheme to represent a text.
When a decimal number is converted to any other system, the integer and the fraction potions
of the number are handled differently. The radix divide technique is used to convert the integer
portion and the radix multiply technique is used for the fraction portion.
Page 47 of 199
Example
1. (245)10 to binary
2 245
2 122 1 LSB
2 61 0
2 30 1
2 15 0
2 7 1
2 3 1
2 1 1
0 1 MSB
N = 111101012
2. 0.62510 to binary
N = 0.1012
3. 24510 to hexadecimal
16 245
16 5 15 MSB
2 0 5 LSB
Page 48 of 199
N = 5F16
4. 2AF16 to decimal
(2×162)+(A×161)+(F×160) = (2×162)+(10×161)+(15×160)
= (512+160+15)10 = 68710
To convert hexadecimal to binary umber, simply replace each hexadecimal bit with its 4 bit
equivalent binary bit
- C416 = 11000100
To convert a binary number to its hexadecimal equivalent, simply group the binary bits at
groups of 4. if necessary, may have to add 0’s to complete the groups
Note
The leading zero that is added to complete the MSB assist us in making 4 bit binary group.
Addition
a) Binary addition
Binary addition takes in consideration of the following conditions
When adding larger numbers, the resulting ones are carried to other higher columns
Page 49 of 199
e.g.
b) hexadecimal addition
Let’s add
1 5 F C
2 4 5 D
3 A 5 9
Page 50 of 199
Subtraction
a) Binary subtraction
In arithmetic subtraction, the initial numeric quotients that are combined by subtraction are
the minuend and the subtrahend.. the result of the subtraction is called the difference
To subtract from a larger binary number, subtract column by column borrowing from adjacent
columns when necessary.
Remember when borrowing from adjacent column, there are two digits
Example
The procedure for this calculation is identical to that of decimal numbers because the smaller
value is subtracted from the larger value and the negative sign placed in front of the results
Page 51 of 199
There are two other methods available for doing subtraction and representation of a negative
number.
i. ones’ compliment
The procedure for subtracting numbers using ones’ compliment is as follows
Step1-change the 0’s of subtra-end to 1’s and the 1’s of subtra-end to 0’s
Example
When there is a carry in the end of the result, then we know the result is positive.
When there is no carry then we know the result is negative and we can now place a minus
sign in front of the answer.
Page 52 of 199
Example
01101 menuend
11011 subtraend
01101
+ 00100
Example
Page 53 of 199
b) Hexadecimal subtraction
Example
Alternatively convert the decimal numbers to binary then subtract using the rules of binary
subtraction.
Multiplication
c) Binary multiplication
Binary numbers are multiplied in the same manner as decimal numbers.
Rules
- To multiply number with more than one digit, you form partial products and add them
together.
Page 54 of 199
Computers cannot store partial products. The multiplication method used by the computer is
repeated additions.
Division
d) Binary division
There are several methods of performing binary division. In the partial method also known as
the restoring method, division is similar to decimal method
Example
Divide 14 by 2
Successive subtraction
Divisor is subtracted from the divided and from each successive remainder until a barrow is
realized. The desired quotient is one less the number of subtraction needed to produce a
borrow. This method is simple but slow for large numbers.
Page 55 of 199
Representation of negative numbers
The examples shown so far have been using positive numbers. In practice, a digital system must
represent all positive and negative numbers. To accommodate the sign of numbers, an additional
digit known as the sign digit is included in the representation along with the magnitude digit.
Thus to represent an n-digit number, we world need n+1 digit.
e) sign-magnitude system
in this representation, n+1 digit are used to represent a number where the MS digit is the sign
digit and the remaining n-digit are the magnitude digit. The value of the sign digit is 0 for a
positive number and r-1 for a negative number, where r is the radix of the number system.
Page 56 of 199
Sign Magnitude Decimal
0 1 1 1 +7
0 1 1 0 +6
0 1 0 1 +5
0 1 0 0 +4
0 0 1 1 +3
0 0 1 0 +2
0 0 0 1 +1
0 0 0 0 0
1 0 0 1 -1
1 0 1 0 -2
1 0 1 1 -3
1 1 0 0 -4
1 1 0 1 -5
1 1 1 0 -6
1 1 1 1 -7
The sign and magnitude portions are handled separately in arithmetic using sign magnitude
number
f) Compliment system
To compliment a binary number, change all 0‘s to 1‘s and all 1‘s to 0‘s. this is known as ones‘
compliment form of a binary number.
The most common way to express a negative binary number is to show it as a two‘s compliment.
A two‘s compliment is a binary number that shows when one is added to the first compliment
Page 57 of 199
Signed Ones’ compliment Two’s compliment
Decimal
+7 0111 0111
+6 0110 0110
+5 0101 0101
+4 0100 0100
+3 0011 0011
+2 0010 0010
+1 0001 0001
0 0000 0000
1 1110 1111
2 1101 1110
3 1100 1101
4 1011 1100
5 1010 1101
6 1001 1010
7 1000 1001
Using the two‘s compliment makes its easier for digital system to perform digital operation. The
correct sign bit is generated by performing the two‘s compliment
a) Alphanumeric codes
Codes have been developed to represent data as well as numbers and special symbols as ‗=‘, ‗&‘,
etc
Page 58 of 199