Chapter 3
Chapter 3
BINARY NUMBER
SYSTEM
Bit: Bit is a short form of binary digit. It is the smallest possible unit of data. In
computerized data a bit can either be 0 or 1.
Bit 1 0
Nibble 4 1010
Data values that can be equivalent, multiply that place holder amount (power of 2) by
represented = 23 = 8
0 000 the digit, and then add them all up.
1 001
2 010 For example, let us convert 1101 into decimal
3 011
4 100
Decimal number = 1*23 + 1*22 + 0*21 + 1*20
5 101
= 1*8 + 1*4 + 0*2 + 1*1
6 110
7 111
=8+4+0+1
= 13
Sixteen’s Column Eight’s column Fours column Twos column Ones column
(LSB)
24 23 22 21 20
© Oxford University Press 2012. All rights reserved.
Convert a Decimal number into a binary number
To convert decimal number into its binary equivalent, simply divide the decimal number
by 2 and then write down the remainder, repeat this process until you cannot divide by 2
anymore.
Let us convert decimal 13 or (13)10 into its binary equivalent
2 | 13 | R
2 | 6 | 1
2 | 3 | 0
2 | 1 | 1
2| 0 | 1
Now write the result starting from the last remainder obtained. Therefore, (13) 10 = (1101)2
Adding binary numbers is not only simple but also similar to the addition of
decimal numbers. While performing binary addition, start by adding the bits
(digits) in one column, or place weight, at a time, from right to left as we do in
case of adding decimal numbers. However, to perform binary addition you
must memorize the rules of addition.
Rules of Binary Addition
0+0=0
0+1=1
1+0=1
1 + 1 = 0, and carry 1 to the next more significant bit
0001010 1010101 11 - CARRY 11111
+ 0100100 + 0101010 1011 1010101
0101110 1111111 + 0001 + 0101110
1100 10000011
2122
22 002002
101101 1 1 1 0 1 1 0 - Minuend
-100111 - 1 0 1 0 1 1 1 - Subtrahend
0 0 0 1 1©
0 Oxford0University
0 1 1 1 1 1Press
- Diff erence
2012. All rights reserved.
SUBTRACTING TWO BINARY NUMBERS USING 2’s
COMPLEMENT
STEP 1: Find the two’s complement of the number to be subtracted (subtrahend).
Two’s complement is calculated in two steps.
Complement each digit of the number. That is, change 1 for 0 and 0 for 1. The
resultant number is said to be in one’s complement form.
Add 1 to the result number in one’s complement form to get the corresponding
two’s complement
STEP 2: Add the minuend and subtrahend (which is now in two’s complement
form). Take care of the carries in each column and discard any carry bit that
extends beyond the number of bit of the original or two's complement.
1011 – 1001
Step 1: Subtrahend = 1001
One’s complement of subtrahend = 0110
Two’s complement of subtrahend = 0110 + 1 = 0111
Step 2: Add minuend and two’s complement of subtrahend
1011
+ 0111
1 0010 Now discard the carry from the last bit, the result = 0010
© Oxford University Press 2012. All rights reserved.
MULTIPLYING TWO BINARY NUMBERS
Two numbers A and B are multiplied using partial products. For each digit in B,
the product of that digit in A is calculated and written on a new line (shifted
leftward). The partial products are added together to get the final result.
The rules of multiplications of binary numbers are same as that of decimal
numbers, that is
0x0=0
0x1=0
1x0=0
1x1=1
1010.* 11 = 11110 111010 * 101 = 100100010 1011 * 1001 = 1100011
1010 111 0 1 0 1 0 11
* 11 *101 *1001
1010 111 0 1 0 1 0 11
10100 0000000 00000
1111 0 111 0 1 0 0 0 000000
100100010 1 0 11 0 0 0
11 0 0 0 11
© Oxford University Press 2012. All rights reserved.
Division of Two Binary Numbers
Binary division is again similar to dividing two decimal numbers. According to the
long division method, the divisor is multiplied with quotient and the result is then
subtracted from the dividend.
0 0 11 0 111 0 1 0 0 1 0 1111
11 ) 1 0 0 1 ( 1 0 ) 111 0 11 ( 1 0 1 ) 111 0 111 0 (
0 0 0
10 11 11
0 10 0
100 11 111
11 10 101
11 10 100
11 10 0
0 01 1001
0 101
11 1001
10 101
1 1001
101
1000
101
11
© Oxford University Press 2012. All rights reserved.
OCTAL NUMBER SYSTEM
The octal numeral system, is the base-8 number system, and uses the digits 0 to
7. This number system was used extensively in early mainframe computer
systems, but has become less popular when compared with binary and
hexadecimal number systems.
In order to convert an octal number into its decimal equivalent, multiply that place
holder amount (power of 8) by the digit, and then add them all up.
To convert decimal number into its octal equivalent, simply divide the decimal
number by 8 and then write down the remainder, repeat this process until you
cannot divide by 2 anymore.
Now write the result starting from the last remainder obtained. Therefore, (786) 10 =
Dec 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Bin 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111
Hex 0 1 2 3 4 5 6 7 8 9 A B C D E F
© Oxford University Press 2012. All rights reserved.
Convert Hexadecimal Number into Binary
Break the binary number into 4-bit groups beginning with the LSB and substitute
the corresponding four bits in binary for each hexadecimal digit in the number.
For example, convert OxABCD into its binary equivalent.
(ABCD)16 = (1010 1011 1100 1101)2
Sign-and-magnitude
Sign-and-magnitude is the simplest technique in which the MSB is set to 0 for a
positive number or zero, and set to 1 for a negative number. The other bits denote
the value or the magnitude of the number.
Ones' complement
The ones'-complement representation of a negative number is obtained by
taking the complement of its positive counterpart (in binary).
So, +45 in binary is 0010 1101
Now negate each bit to obtain the binary representation of -45.
Hence, -45 in binary = 1101 0010
In excess-3 coding technique, each decimal digit is the 4-bit binary equivalent
with 3 (0011) added.
Weighted binary codes are those in which each position of the number represents
a specific weight. For ex, we have 8421, 2421, 5211, and 4221 codes.
In 8421 BCD code, the code is a straight assignment of the binary equivalent.
Every position in the BCD is assigned a weight of 8,4,2,1. For ex, the bit
assignment in 1010 represent decimal 10 because 1*8 + 0*4 + 1*2 + 0*1 = 10
In 4221 coding, each digit is represented as a 4-bit group and each bit represents
4, 2, 2, and 1 instead of 8, 4, 2 and 1. For ex, 7 in 4241 can be written as, 1101
because 1*4 + 1*2 + 0*2 + 1*1 = 7
The gray code is minimum change code, in which only one bit in the code
changes from one code to the next. It is a non-weighted code. Gray code of a
number is obtained from its binary code. To derive the Gray code of a
number,
Copy the MSB of the binary code as the MSB of the Gray code
Repetitively add MSB and the bit next to the MSB to get the corresponding
bit for the Gray code
AND Gate: The AND gate i accepts two inputs and gives an output. The o/p will be
‘1’ if and only if both the inputs are ‘1’ and a zero otherwise.
OR Gate: The OR gate accepts two inputs and gives an output. The output will be
‘1’ if any of the two is a ‘1’.
NOT Gate: The NOT gate accepts just one input. The output produced by a NOT
gate is just the opposite of the input.
NAND Gate: The NAND gate the opposite of the AND gate. It accepts two inputs
and returns 1 of any one of the input is a 1 but not both.
© Oxford University Press 2012. All rights reserved.
LOGIC GATES (Contd.)
NOR Gate: The NOR gate the opposite of the OR gate. The NOR gate accepts
two inputs and returns 1 only of both the inputs are low (zero).
XOR Gate: The X in the XOR gate stands for "exclusive." This means that the
output from this gate will be a 1 if only one of the inputs is a 1 and not both.
XNOR Gate: The XNOR gate is the opposite of the XOR gate. It accepts two
inputs and returns 1 only if both the inputs are same and a 0 otherwise.