number system cs1301(sm2) (sm2...0ctal to hexadecimal conversion step 1: convert octal number to...

36
NUMBER SYSTEM CS1301(SM2)

Upload: others

Post on 25-Dec-2020

20 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: NUMBER SYSTEM CS1301(SM2) (SM2...0ctal to hexadecimal conversion Step 1: Convert octal number to equivalent binary number. Step 2: Make group bits in fours, starting on right and convert

NUMBER SYSTEMCS1301(SM2)

Page 2: NUMBER SYSTEM CS1301(SM2) (SM2...0ctal to hexadecimal conversion Step 1: Convert octal number to equivalent binary number. Step 2: Make group bits in fours, starting on right and convert

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

Page 3: NUMBER SYSTEM CS1301(SM2) (SM2...0ctal to hexadecimal conversion Step 1: Convert octal number to equivalent binary number. Step 2: Make group bits in fours, starting on right and convert

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

Page 4: NUMBER SYSTEM CS1301(SM2) (SM2...0ctal to hexadecimal conversion Step 1: Convert octal number to equivalent binary number. Step 2: Make group bits in fours, starting on right and convert

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

Page 5: NUMBER SYSTEM CS1301(SM2) (SM2...0ctal to hexadecimal conversion Step 1: Convert octal number to equivalent binary number. Step 2: Make group bits in fours, starting on right and convert

DATA AND BINARY REPRESENTATION

Page 6: NUMBER SYSTEM CS1301(SM2) (SM2...0ctal to hexadecimal conversion Step 1: Convert octal number to equivalent binary number. Step 2: Make group bits in fours, starting on right and convert

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.

Page 7: NUMBER SYSTEM CS1301(SM2) (SM2...0ctal to hexadecimal conversion Step 1: Convert octal number to equivalent binary number. Step 2: Make group bits in fours, starting on right and convert

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.

Page 8: NUMBER SYSTEM CS1301(SM2) (SM2...0ctal to hexadecimal conversion Step 1: Convert octal number to equivalent binary number. Step 2: Make group bits in fours, starting on right and convert

NUMBER SYSTEM CONVERSION

Page 9: NUMBER SYSTEM CS1301(SM2) (SM2...0ctal to hexadecimal conversion Step 1: Convert octal number to equivalent binary number. Step 2: Make group bits in fours, starting on right and convert

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

Page 10: NUMBER SYSTEM CS1301(SM2) (SM2...0ctal to hexadecimal conversion Step 1: Convert octal number to equivalent binary number. Step 2: Make group bits in fours, starting on right and convert

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”

Page 11: NUMBER SYSTEM CS1301(SM2) (SM2...0ctal to hexadecimal conversion Step 1: Convert octal number to equivalent binary number. Step 2: Make group bits in fours, starting on right and convert

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.

Page 12: NUMBER SYSTEM CS1301(SM2) (SM2...0ctal to hexadecimal conversion Step 1: Convert octal number to equivalent binary number. Step 2: Make group bits in fours, starting on right and convert

Example12510 = ?2

2 125

62 12

31 02

15 12

7 12

3 12

1 12

112510 = 11111012

Page 13: NUMBER SYSTEM CS1301(SM2) (SM2...0ctal to hexadecimal conversion Step 1: Convert octal number to equivalent binary number. Step 2: Make group bits in fours, starting on right and convert

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.

Page 14: NUMBER SYSTEM CS1301(SM2) (SM2...0ctal to hexadecimal conversion Step 1: Convert octal number to equivalent binary number. Step 2: Make group bits in fours, starting on right and convert

Example.63410 = ?2

Page 15: NUMBER SYSTEM CS1301(SM2) (SM2...0ctal to hexadecimal conversion Step 1: Convert octal number to equivalent binary number. Step 2: Make group bits in fours, starting on right and convert

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

Page 16: NUMBER SYSTEM CS1301(SM2) (SM2...0ctal to hexadecimal conversion Step 1: Convert octal number to equivalent binary number. Step 2: Make group bits in fours, starting on right and convert

Example

7248 => 4 x 80 = 4

2 x 81 = 16

7 x 82 = 448

46810

Page 17: NUMBER SYSTEM CS1301(SM2) (SM2...0ctal to hexadecimal conversion Step 1: Convert octal number to equivalent binary number. Step 2: Make group bits in fours, starting on right and convert

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

Page 18: NUMBER SYSTEM CS1301(SM2) (SM2...0ctal to hexadecimal conversion Step 1: Convert octal number to equivalent binary number. Step 2: Make group bits in fours, starting on right and convert

Example

ABC16 =>C x 160 = 12 x 1 = 12

B x 161 = 11 x 16 = 176

A x 162 = 10 x 256 = 2560

274810

Page 19: NUMBER SYSTEM CS1301(SM2) (SM2...0ctal to hexadecimal conversion Step 1: Convert octal number to equivalent binary number. Step 2: Make group bits in fours, starting on right and convert

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

Page 20: NUMBER SYSTEM CS1301(SM2) (SM2...0ctal to hexadecimal conversion Step 1: Convert octal number to equivalent binary number. Step 2: Make group bits in fours, starting on right and convert

Binary to OctalTechnique

◦ Make group bits in threes, starting on right

◦ Convert to octal digits

Page 21: NUMBER SYSTEM CS1301(SM2) (SM2...0ctal to hexadecimal conversion Step 1: Convert octal number to equivalent binary number. Step 2: Make group bits in fours, starting on right and convert

Example10110101112 = ?8

1 011 010 111

1 3 2 7

10110101112 = 13278

Page 22: NUMBER SYSTEM CS1301(SM2) (SM2...0ctal to hexadecimal conversion Step 1: Convert octal number to equivalent binary number. Step 2: Make group bits in fours, starting on right and convert

Binary to HexadecimalTechnique◦ Make group bits in fours, starting on right

◦ Convert to hexadecimal digits

Page 23: NUMBER SYSTEM CS1301(SM2) (SM2...0ctal to hexadecimal conversion Step 1: Convert octal number to equivalent binary number. Step 2: Make group bits in fours, starting on right and convert

Example

10101110112 = ?16

10 1011 1011

2 B B

10101110112 = 2BB16

Page 24: NUMBER SYSTEM CS1301(SM2) (SM2...0ctal to hexadecimal conversion Step 1: Convert octal number to equivalent binary number. Step 2: Make group bits in fours, starting on right and convert

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

Page 25: NUMBER SYSTEM CS1301(SM2) (SM2...0ctal to hexadecimal conversion Step 1: Convert octal number to equivalent binary number. Step 2: Make group bits in fours, starting on right and convert

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

Page 26: NUMBER SYSTEM CS1301(SM2) (SM2...0ctal to hexadecimal conversion Step 1: Convert octal number to equivalent binary number. Step 2: Make group bits in fours, starting on right and convert

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

Page 27: NUMBER SYSTEM CS1301(SM2) (SM2...0ctal to hexadecimal conversion Step 1: Convert octal number to equivalent binary number. Step 2: Make group bits in fours, starting on right and convert

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

Page 28: NUMBER SYSTEM CS1301(SM2) (SM2...0ctal to hexadecimal conversion Step 1: Convert octal number to equivalent binary number. Step 2: Make group bits in fours, starting on right and convert

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

Page 29: NUMBER SYSTEM CS1301(SM2) (SM2...0ctal to hexadecimal conversion Step 1: Convert octal number to equivalent binary number. Step 2: Make group bits in fours, starting on right and convert

BINARY CODED DECIMAL

Page 30: NUMBER SYSTEM CS1301(SM2) (SM2...0ctal to hexadecimal conversion Step 1: Convert octal number to equivalent binary number. Step 2: Make group bits in fours, starting on right and convert

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.

Page 31: NUMBER SYSTEM CS1301(SM2) (SM2...0ctal to hexadecimal conversion Step 1: Convert octal number to equivalent binary number. Step 2: Make group bits in fours, starting on right and convert

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.

Page 32: NUMBER SYSTEM CS1301(SM2) (SM2...0ctal to hexadecimal conversion Step 1: Convert octal number to equivalent binary number. Step 2: Make group bits in fours, starting on right and convert

ASCII AND EBCDIC CODE

Page 33: NUMBER SYSTEM CS1301(SM2) (SM2...0ctal to hexadecimal conversion Step 1: Convert octal number to equivalent binary number. Step 2: Make group bits in fours, starting on right and convert

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)

Page 34: NUMBER SYSTEM CS1301(SM2) (SM2...0ctal to hexadecimal conversion Step 1: Convert octal number to equivalent binary number. Step 2: Make group bits in fours, starting on right and convert

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

Page 35: NUMBER SYSTEM CS1301(SM2) (SM2...0ctal to hexadecimal conversion Step 1: Convert octal number to equivalent binary number. Step 2: Make group bits in fours, starting on right and convert

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.

Page 36: NUMBER SYSTEM CS1301(SM2) (SM2...0ctal to hexadecimal conversion Step 1: Convert octal number to equivalent binary number. Step 2: Make group bits in fours, starting on right and convert

EBCDIC CODE