number system cs1301(sm2) (sm2...0ctal to hexadecimal conversion step 1: convert octal number to...
TRANSCRIPT
NUMBER SYSTEMCS1301(SM2)
Contents
1 DEF. and IT’S GENERAL REPRESENTATION OF NUMBER SYSTEM
2 DATA AND BINARY REPRESENTATION
3 CODES AND NUMBER SYSTEM CONVERSION
4 BINARY CODED DECIMAL
5 ASCII AND EBCDIC CODE
6 GRAY CODE
7 EXCESS-3 CODE
8 SIGNED BINARY NO REPRESENTATION WITH 1’S AND 2’S COMPLEMENT
9 BINARY ARITHEMATIC
Definition of Number System A number system is a framework where a set of numbers are represented by numerals in a consistent manner.
Eg: “11”
Ideally Number system will:• Represent a useful set of numbers
• Give every number represented by a unique representation
• Reflect the algebraic and arithmetic structure of the numbers
Representation of Number
𝑁 𝑟 = 𝑑𝑛−1𝑑𝑛−2 −−−−𝑑0 𝑅𝑎𝑑𝑖𝑥 . 𝑑−1𝑑−2 −−−−𝑑−𝑚
Fractional PartInteger Part
Base
Point
Radix Number System Digital System
2 Binary 0, 1
3 Ternary 0, 1, 2
4 Quaternary
8 Octal
10 Decimal
16 Hexadecimal
DATA AND BINARY REPRESENTATION
Data representation
How do computers represent data?
Computers are digital and use electricity
Recognize only two discrete states: on/off
Use a Binary System to recognize 2 states
Use Number System with 2 unique digits: 0 & 1, called bits.
Binary representationThe basis of all digital data is binary representation.
The binary number system is the means of representing quantities using only 2 digits: 0 and 1.
Like Other Number systems its based on Positional Notation.
The Binary No system is also known as Base 2.
The values of the position are calculated by taking 2 to some power.
NUMBER SYSTEM CONVERSION
Binary to DecimalTechnique◦ Multiply each bit by 2n, where n is the “weight” of the bit
◦ The weight is the position of the bit, starting from 0 on the right
◦ Add the results
Example
1010112 => 1 x 20 = 1
1 x 21 = 2
0 x 22 = 0
1 x 23 = 8
0 x 24 = 0
1 x 25 = 32
4310
Bit “0”
Decimal to BinaryProcedural Steps:
Integer Part◦ Divide by two, keep track of the remainder
◦ First remainder is bit 0 (LSB, least-significant bit)
◦ Second remainder is bit 1
◦ Etc.
Example12510 = ?2
2 125
62 12
31 02
15 12
7 12
3 12
1 12
112510 = 11111012
Decimal to BinaryProcedural Steps:
Fractional Part◦ Repeatedly multiply the given fraction by 2
◦ Accumulate the integer part (0 or 1)decimal point
◦ If the integer part is 1, chop it off
◦ Stop the above step until fractional part is zero or up to some significant bits.
◦ Arrange the integer part in the order they are obtained.
Example.63410 = ?2
Octal to DecimalTechnique
◦ Multiply each bit by 8n, where n is the “weight” of the bit
◦ The weight is the position of the bit, starting from 0 on the right
◦ Add the results
Example
7248 => 4 x 80 = 4
2 x 81 = 16
7 x 82 = 448
46810
Hexadecimal to DecimalTechnique
◦ Multiply each bit by 16n, where n is the “weight” of the bit
◦ The weight is the position of the bit, starting from 0 on the right
◦ Add the results
Example
ABC16 =>C x 160 = 12 x 1 = 12
B x 161 = 11 x 16 = 176
A x 162 = 10 x 256 = 2560
274810
r number system to decimal conversion
r number can be converted to its equivalent decimal by
1. The bits in the left of decimal point are multiplied by power 𝑟0, 𝑟1, 𝑟2… .
and add the weights
1. The bits in the right of decimal point are multiplied by power 𝑟−1, 𝑟−2… .
and add the weights
Example, 1011.101 2 = (? )10
Binary to OctalTechnique
◦ Make group bits in threes, starting on right
◦ Convert to octal digits
Example10110101112 = ?8
1 011 010 111
1 3 2 7
10110101112 = 13278
Binary to HexadecimalTechnique◦ Make group bits in fours, starting on right
◦ Convert to hexadecimal digits
Example
10101110112 = ?16
10 1011 1011
2 B B
10101110112 = 2BB16
Hexadecimal to binary conversion
Ex. (AB3.D5)16 = (?)2
1011
→ (AB3.D5)16 = (101010110011.11010101)2
Replace each digit of hexadecimal to its equivalent 4
bit binary number.
1010 0011
1101
0101
Octal to binary conversion
Ex. (643.15)8 = (?)2
100
→ (643.15)8 = (110100011.001101)2
Replace each digit of octal to its equivalent 3 bit
binary number.
110 011
001
101
0ctal to hexadecimal conversionStep 1: Convert octal number to equivalent binary
number.
Step 2: Make group bits in fours, starting on right
and convert 4 bits binary number to its equivalent
hexadecimal digits.
Ex. (643.15)8 = (?)16
0ctal to hexadecimal conversionEx. (643.15)8 = (?)2 =(?)16
100
→ (643.15)8 = (110100011.001101)2
110011001
101
320001=1 3 0100=4
→ (643.15)8 = (123.34)16
Hexadecimal to octal conversionStep 1: Convert hexadecimal number to equivalent
binary number.
Step 2: Make group bits in threes, starting on right
and convert 3 bits binary number to its equivalent
octal digits.
Ex. (6AB.F5)16 = (?)8
BINARY CODED DECIMAL
BINARY CODED DECIMAL (BCD)
Method to represent Decimal digits using binary.
Also known as 8421 Code
The BCD is simply the 4 bit representation of the decimal digit.
For multiple digit base 10 numbers, each symbol is represented by its BCD digit.
Use: Electric counter, Digital voltmeter etc.
BINARY CODED DECIMALQ: How would 91610 be represented in binary coded decimal?
Solution
Since the binary codes for 9, 1 and 6 are 1001, 0001 and 0110 respectively, then 91610 =100100010110BCD. Note that the BCD code is 12 bits long since each of the decimal digits iscoded by four bits.
ASCII AND EBCDIC CODE
ASCII CODE
In 1963, ANSI (American National Standards Institute) brought ASCII code.
American Standard Code for Information Interchange.
The ASCII is a 8 bits code whose format is X7X6X5X4X3X2X1X0 where each X is 0 or 1.
It has 128 characters
First 32 characters (control operations)◦ backspace (8)
line feed (10)
escape (27)
ASCII Character SetCharacter Code Character Code Character Code
a 97 A 65 0 48
b 98 B 66 1 49
c 99 C 67 2 50
d 100 D 68 3 51
e 101 E 69 4 52
f 102 F 70 5 53
g 103 G 71 6 54
h 104 H 72 7 55
i 105 I 73 8 56
j 106 J 74 9 57
k 107 K 75 ! 33
l 108 L 76 # 35
m 109 M 77 $ 36
n 110 N 78 % 37
o 111 O 79 & 38
p 112 P 80 ( 40
q 113 Q 81 ) 41
r 114 R 82 * 42
s 115 S 83 + 43
t 116 T 84 , 44
u 117 U 85 . 46
v 118 V 86 ; 59
w 119 W 87 = 61
x 120 X 88 ? 63
y 121 Y 89 @ 64
z 122 Z 90 ^ 94
EBCDIC CODE
It is pronounced as ebb-see-dick.
It is Extended Binary Coded Decimal Interchange Code.
It is standard code for character encoding used by IBM in large Computers.
It is 8 bit code without parity.
Has wider range of control characters than ASCII.
EBCDIC CODE