Number System 2010
[email protected] Page 1
Decimal Number System • It is a base 10 numbering system consisting of 10 numbers
0,1,2,3,4,5,6,7,8 and 9. • Also called Denary. • Represented as (123)10 (here 10 is the radix of a decimal number
system)
Conversion:
1. Decimal to Binary Ex: (74)10 = (?)2
Radix Number Remainder
2 74 0(LSB)
2 37 1
2 18 0
2 9 1
2 4 0
2 2 0
1 1(MSB)
(74)10 = (1001010)2
Ex: Fractional decimal to binary
(0.625)10 = (?)2 0.625*2 = 1.25 0.25*2 = 0.5 0.5*2 = 1
Number System 2010
[email protected] Page 2
Fractional Decimal
Operation Product Fractional part
Integer part
0.625 Multiply by 2 1.25 0.25 1(MSB)
0.25 Multiply by 2 0.50 0.50 0
0.5 Multiply by 2 1.00 0.00 1(LSB)
Hence, (0.625)10 = (0.101)2 Do this:
1. (8.75)10 -> (?)2
2. (0.8125)10 -> (?)2
2. Decimal to Octal Ex: (74)10 = (?)8
Radix Number Remainder
8 74 2(LSD)
8 9 1
1 1(MSD)
(74)10 = (112)8
Ex: (.96)10 = (?)8
Fraction Fraction *8 Remainder Integer
0.96 7.68 .68 7(MSD)
.68 5.44 .44 5
.44 3.52 .52 3
.52 4.16 .16 4
.16 1.28 .28 1(LSD)
And so on (.96)10 = (.75341)8
3. Decimal to Hexadecimal
Ex: (256)10 = (?)16
Number System 2010
[email protected] Page 3
Radix Number Remainder
16 256 0(LSD)
16 16 0
1 1(MSD)
(256)10 = (100)16
Ex: (952)10 = (?)16
Radix Number Remainder
16 952 8(LSD)
16 59 11 -> B
3 3(MSD)
(952)10 = (3B8)16
Ex: (.62)10 = (?)16
Fraction Fraction *16 Remainder Integer
0.62 9.92 .92 9(MSD)
.92 14.72 .72 14->E
.72 11.52 .52 11->B
.52 8.32 .32 8
.32 5.12 .12 5
.12 1.92 0.92 1(LSD)
And so on (.62)10 = (.9EB851)16
Binary System
• A number expressed in binary form i.e 0 and 1. It is represented by base 2. eg (10)2
• Computer use this number system for their internal processing. • 1 indicates high voltage and o indicates low voltage. • 1 is yes or on and 0 is no or off. • Invented by Francis Bacon in 1623 AD
Conversion:
1. Binary to Decimal Ex: (1101)2 -> (?)10 =1*23 +1*22 +0*21 + 1*20 =1* 8 + 1*4 +0*2 + 1*1
Number System 2010
[email protected] Page 4
=8 +4 + 0 + 1 =13 (1101)2 -> (13)10 Ex: (.1101)2 -> (?)10 =1*2-1 +1*2-2 +0*2-3 + 1*2-4
=1* 1
2 + 1*
1
4 +0*
1
8 + 1*
1
16
=0.5 +0.25 + 0 + 0.0625 =0.8125 (.1101)2 -> (0.8125)10
2. Binary to Octal Ex: (101010)2 ->(?)8
101010 ->101 010 101 ->5 010 ->2
(101010)2 -> (52)8 Ex: (1011.1011)2-> (?)8 001 011 . 101 100 1 3 5 4 (1011.1011)2-> (13.54)8
3. Binary to Hexadecimal Ex: (1010101011)2 -> (?)16
0010 1010 1011
2 10 11 A B (1010101011)2 -> (2AB)16
Number System 2010
[email protected] Page 5
Ex: (1011100.1000101)2 -> (?)16
0101 1100 . 1000 1010 Add 5 C . 8 A
(1011100.1000101)2 -> (5C.8A)16
Octal Number System • Octal means eight which came from Latin “octo”. • It is a base 8 number system consisting of eight digits 0,1,2,3,4,5,6 and 7. • The octal system is used in programming as a compact means of
representing binary numbers. • Represented as (23)8 Table for octal system
Octal Binary Decimal
0 000 0
1 001 1
2 010 2
3 011 3
4 100 4
5 101 5
6 110 6
7 111 7
Conversion 1. Octal into Binary
(52)8 = (?)2 (27)8 = (?)2
We know, We know,
5=101 2=010 2=010 7=111
(52)8 = (101010)2 (27)8 = (010111)2 Ex: (56.34)8-> (?)2 5-> 101 6->110 3->011
Number System 2010
[email protected] Page 6
4->100 (101)(110).(011)(100) Adding (56.34)8-> (101110.011100)2
2. Octal to decimal (52)8 = (?)10 (213)8 = (?)10
(52)8 = 5*81 + 2*80 (213)8 = 2*82 + 1*81 + 3*80
= 42 = 128+8+3 = 139 (52)8 = (42)10 (213)8 = (139)10
Ex: (.563)8-> (?)10 =5*8-1 + 6*8-2 +3*8-3
=0.625 +0.09375 +0.005859375 =0.724609375 (.563)8-> (0.724609375)10
Ex: (127.54)8 = (?)10
= 1*82 + 2*81 + 7*80 + 5*8-1 + 4*8-2 = 64+16+7+0.625+0.0625 = 87.6875 Hence, (127.54)8 = (87.6875)10
3. Octal to hexadecimal (52)8 = (?)16 (127)8 = (?)16
We know. We know, 2=010 7=111 5=101 2=010 1=001
Number System 2010
[email protected] Page 7
=(101010)2 =(1010111)2
1010=A 0010=2 0111=7 101=5 =(2A)16
=(57)16
Ex: (6.57)8->(?)16 6->110 5->101 7->111 (6.57)8->(110.101111)2 110 . 1011 11 0110 . 1011 1100 Adding 6 . B C (6.57)8-> (6.BC)16
Number System 2010
[email protected] Page 8
Hexadecimal Number System
The hexadecimal system used the digits 0 to 9 and the letters A to F to represent the decimal numbers 10 to 15.
16 digits are used(0,1,2,3,4,5,6,7,8,9,A,B,C,D,E and F)
It is a base 16 system.
Represented as (2A)16. Conversion 1. Hexadecimal to Binary
Ex: (6D.3A)16 ->(?)2 6->110 D->1101 3->11 A->1010 (6D.3A)16 ->(1101101.00111010)2
2. Hexadecimal to Octal Ex: (D.3A)16 ->(?)8 D->1101 3->11(0011) A->1010 (D.3A)16 ->(1101.00111010)2
001 101 . 001 110 100
1 5 1 6 4
(D.3A)16 ->(15.164)8
3. Hexadecimal to Decimal Ex: (2B6)16 ->(?)10
2*162 + B*161 + 6*160 2*256 +B *16 +6 512+176+6 694
Adding 0 back side
Adding 0 in front
Number System 2010
[email protected] Page 9
(2B6)16 ->(694)10 Ex: (.5A)16 ->(?)10
=5*16-1 + A*16-2 =0.3125 +0.0390625 =0.3515625 (.5A)16 ->(0.3515625)10
Number System 2010
[email protected] Page 10
Binary Algebra
1. Binary Addition
0 + 0 = 0 1 + 0 = 1 0 + 1 = 1 1 + 1= 10 (0 with a carry over 1)
Example:
011001 110001
1001010
2. Binary Subtraction
0 - 0 = 0 1 - 0 = 1 0 - 1 = 1(with borrowing 1) 1 - 1= 0
Example: 110001 011001
011000
3. Binary Multiplication
0 * 0 = 0 1 * 0 = 1 0 * 1 = 1 1 * 1 = 1
Example:
Number System 2010
[email protected] Page 11
4. Binary Division
0 ÷ 0 = 0 1 ÷ 0 = (not defined) 0 ÷ 1 = 1 1 ÷ 1 = 1
Number System 2010
[email protected] Page 12
Complement
9’s Complement -is obtained by subtracting each digit’s from 9 Ex: 9’s Complement of 5 is 4 9’s Complement of 321is 678 10’s Complement
-10’s Complement of a decimal number is obtained by adding 1 to the 9’s Complement of a number
Ex: 9’s complement of 73 is 26 10’s Complement of 73 is 26+1 =27
Now, Number + 10’s Complement of a number is 0. 73 +27=100 (neglect 1) Now, 73 - 23 = 50 73 + (10’s complement of 23 i.e 77) =150(ignore 1 as we are doing for 2 bit only) Ex:
73-77 -> the result will be in 10’s complement form 73-77 = -4 73 + (10’s complement of 77 i.e 23) = 96 (96 = (99-04)+1) 96 is the 10’s complement of 4. So we can say that 10’s complement represents the negative number). The answer is -4
Ex: -26 and -43
Decimal System
9’s Complement
10’s Complement
Binary System
1’s Complement
2’s Complement
Number System 2010
[email protected] Page 13
10’s Complement of 26 is 74 10’s Complement of 43 is 57 Add 74+57= 131 (neglect 1) 31= ((99-69) +1) is the 10’s complement of 69 So the answer is -69.
1’s Complement
-is obtained by subtracting each bit from 1. Eg: 1’s complement of 1010 is 0101
Subtraction of Binary Number using 1’s Complement Method Steps:
1. Make the both numbers having same number of bits 2. Determine the 1’s complement of the number to be subtracted
(subtrahend). 3. Add the 1’s complement to the given number from which we subtract
(minuend). 4. If there exists any additional bit (carry) in the result after addition,
remove and add it to the result else (i.e if there exits no any carry) determine the 1’s complement of the result and prefix by negative sign to the final result.
Example:
a. Subtract 100110 from 110001
1’s complement of 100110 is 011001 Add it with minuend (110001) 110001 1001010 So there exits a carry bit so add it 001010 +1 001011 So the difference is 1011
b. Subtract 110001 from 100110 1’s complement of 110001 is 001110
Number System 2010
[email protected] Page 14
Add it with minuend (100110) 100110 110100 Since there exists no carry bit so the result is the 1’s complement of 110100 Hence the difference is -1011
2’s Complement 2’s complement is obtained by adding 1 to 1’s complement of binary digits. Subtraction using 2’s Complement Steps:
1. Make the both numbers having same number of bits 2. Determine the 2’s complement of the number to be subtracted
(subtrahend). 3. Add the 2’s complement to the given number from which we subtract
(minuend). 4. If there exists any additional bit (carry) in the result after addition,
neglect the carry bit and remaining is the result else (i.e if there exits no any carry) determine the 2’s complement of the result and prefix by negative sign to the final result.
Example:
a. Subtract 100110 from 110001 b. Subtract 110001 from 100110
Signed and Unsigned Number Representation
- In computer we cannot put – or + sign before integer - 0 is placed before a binary number to represent positive
Number System 2010
[email protected] Page 15
- 1 is placed before a binary number to represent a negative number
So, 9 -> 0 1001 -9-> 1 1001
Negative number can be represented by following ways
i. Signed Magnitude 1 1001 ii. Signed 1’s Complement method 1 0110 iii. Signed 2’s Complement method 1 0111
8 bit representation 7 bit is used to represent the number and 1 bit is used to represent the sign -9 can be represented as Signed- magnitude 1 0001001 1’s Complement method 1 1110110 2’s Complement method 1 1110111 Fixed Point Representation of a Number A number which has both an integer part and a fractional part is called a real number or a floating point number. Fixed Point Representation automatically keeps track of the position if the binary or decimal point. Real No Scientific Notation 123.23 1.2323 x 102 0.008 0.8 x 10-2
N= mre Where m= mantissa r = radix of the number system e = exponent 123.23 sign 0 sign 0 Mantissa .12323 exponent 03 -123.23 sign 0 sign 0
Number System 2010
[email protected] Page 16
Mantissa .12323 exponent 03 -0.0012323 sign 1 sign 1 Mantissa .12323 exponent 02
Binary Coded Decimal BCD is the representation which uses 4 bits to represent a decimal
number. Ex: 2 -> 0010
21-> 0010 0001
Disadvantage: difficult to form a complements when numbers are represented in BCD Solution: to overcome this Excess-3 code is used Gray Code: Gray Code is a binary code used in shaft encoder which indicates the angular position of a shaft in digital form. The binary bits are arranged in such a way that only one binary bit changes at a time when we make a change from any numbers to the next. So, largest possible error will be one least significant digits. Used in computer controlled lathes.( Machine tool for shaping metal or wood)
Eg: 7 -> 8 (7 to 8) Gray Code -> 0100 -> 1100 In binary ->0111 -> 1000 If u miss one in binary u miss every thing but in gray code if u miss 1 then it will be 7 .( miss indicated not detected by sensors.)
Number System 2010
[email protected] Page 17
Excess-3 Code:
- To overcome the disadvantage of BCD in forming complements,Excess-3 code is used
- This code is formed by adding 3 to the decimal number and then forming the binary coded number. Eg: for 6 6+3=9 BCD -> 0110 Excess-3 -> 1001
Decimal BCD Excess-3
0 0000 0011
1 0001 0100
2 0010 0101
3 0011 0110
4 0100 0111
5 0101 1000
6 0110 1001
ASCII Code: American Standard Code for Information Interchange (ASCII).
- Used in small computers peripherals, instruments and communication devices.
- Is seven-bit code. - 8th is used for parity or it may be permanently 1 or 0. - With 7 bits -> 128 characters can be represented.
ASCII-8 Code:
- 8 bit code - Capacity -> 256 character
EBCDIC Code : Extended binary coded Decimal information interchange Code. Used for large computer
Is 8 bit without parity, for parity 9th bit is used. In ASCII-8 and EBCDIC
- First 4 bit is known as zone bit - Next 4 bit is a digital values
Number System 2010
[email protected] Page 18
In ASCII
- First 3 bit zone bits - Remaining 4 digit values
Character ASCII EBCDIC
0 0011 0000 1111 0000
1 0011 0001 1111 0001
2 0011 0010 1111 0010
9 0011 1001 1111 1001
A 0100 0001 1100 0001
B 0100 0010 1100 0010
H 0100 1000 1100 1000
P 0101 0000 1101 0111
Bits, Bytes and Words Bits -> 0,1 Bytes -> 8 bits -Storage location using EBCDIC or ASCII-8 codes representing 8 bits can hold one character A 32 bit world length computer might have registers with a capacity 32 bits and transfer data and instructions within the CPU with a group of 32 bits.