number system'.pptx

29
BINARY SYSTEM

Upload: bramara-sri

Post on 12-Jul-2016

220 views

Category:

Documents


3 download

TRANSCRIPT

BINARY SYSTEM

Contents:

1. INFORMATION REPRESENTATION2. Binary Numbers3. Number Base Conversions4. Octal and Hexadecimal Numbers5. Complements6. Signed Binary Numbers7. Binary Codes8. Binary Logic

INFORMATION REPRESENTATION:

1. INFORMATION REPRESENTATION2. Binary Numbers3. Number Base Conversions4. Octal and Hexadecimal Numbers5. Complements6. Signed Binary Numbers7. Binary Codes8. Binary Storage and Registers9. Binary Logic

INFORMATION REPRESENTATION

Digital system examples: Digital telephones, digital TV, DVD, digital cameras (DC), digital videos (DV), and digital computers.

Digital systems: Manipulate discrete data Binary: Numbers are presented by two discrete values (0 and 1),

Binary digit = Bit Group of bits: Binary code Digital systems: A system manipulates discrete elements of

information that is represented internally binary form. HDL (Hardware description language): A programming language

and suitable for describing digital circuits in textual form.

INFORMATION REPRESENTATION

•Numbers are important to computersRepresent information preciselyCan be processed

•ExamplesRepresent yes or no: use 0 and 1Represent the 4 seasons: 0, 1, 2 and 3

•Sometimes, other characters are usedMatriculation number: 8 alphanumeric characters (e.g. U071234X)

INFORMATION REPRESENTATION

• Bit (Binary digit)0 and 1Represent false and true in logicRepresent the low and high states in electronic

devices

• Other unitsByte: 8 bitsNibble: 4 bits (seldom used)Word: Multiples of byte (e.g. 1 byte, 2

bytes, 4 bytes, 8 bytes, etc.), depending on the architecture of the computer system

INFORMATION REPRESENTATION

N bits can represent up to 2N values. Examples:

2 bits represent up to 4 values (00, 01, 10, 11)3 bits rep. up to 8 values (000, 001, 010, …, 110, 111)4 bits rep. up to 16 values (0000, 0001, 0010, …., 1111)

To represent M values, log2M bits are required.Examples:

32 values requires 5 bits64 values requires 6 bits1024 values requires 10 bits

Binary Numbers:

1. Information Representation2. Binary Numbers3. Number Base Conversions4. Octal and Hexadecimal Numbers5. Complements6. Signed Binary Numbers7. Binary Codes8. Binary Logic

DECIMAL (BASE 10) SYSTEM

o A weighted-positional number system

Base or radix is 10 (the base or radix of a number system is the total number of symbols/digits allowed in the system)

Symbols/digits = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 } Position is important, as the value of each

symbol/digit is dependent on its type and its position in the number.

Example, the 9 in the two numbers below has different values:

(7594)10 = (7 × 103) + (5 × 102) + (9 × 101) + (4 × 100)

(912)10 = (9 × 102) + (1 × 101) + (2 × 100)

Decimal number 7392:

7392=7×103+ 3 ×102+ 9 ×101+ 2 ×100

Decimal number representation:In general,

(anan-1… a0 . f1f2 … fm)10 = (an x 10n) + (an-1x10n-1) + … + (a0 x 100) + (f1 x 10-1) + (f2 x 10-2) + … + (fm x 10-m)

Decimal Number with Binary Number:

11010.11=26.75⇒1×24+ 1×23+ 0×22+ 1×21+ 0×20+1×2-1+ 1×22

=26.75 To evaluate the decimal number 593.68, the digit in

each position is multiplied by the corresponding weight:5102 + 9101 + 3100 + 610-1 + 810-2

= (593.68)10

OTHER NUMBER SYSTEMS

Binary (base 2)◦ Weights in powers of 2◦ Binary digits (bits): 0, 1

Octal (base 8)◦ Weights in powers of 8◦ Octal digits: 0, 1, 2, 3, 4, 5, 6, 7.

Hexadecimal (base 16)◦ Weights in powers of 16◦ Hexadecimal digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A,

B, C, D, E, F.Base/radix R:

◦ Weights in powers of R

Number Base Conversions

1. Digital Systems2. Binary Numbers3. Number Base Conversions4. Octal and Hexadecimal Numbers5. Complements6. Signed Binary Numbers7. Binary Codes8. Binary Logic

DECIMAL TO BINARY CONVERSION

o Method 1• Sum-of-Weights Method.

o Method 2• Repeated Division-by-2 Method (for whole

numbers)• Repeated Multiplication-by-2 Method (for

fractions)

SUM-OF-WEIGHTS METHOD

Determine the set of binary weights whose sum is equal to the decimal number

(9)10 = 8 + 1 = 23 + 20 = (1001)2

(18)10 = 16 + 2 = 24 + 21 = (10010)2

(58)10 = 32 + 16 + 8 + 2 = 25 + 24 + 23 + 21 = (111010)2

(0.625)10 = 0.5 + 0.125 = 2-1 + 2-3 = (0.101)2

REPEATED DIVISION-BY-2

To convert a whole number to binary, use successive division by 2 until the quotient is 0. The remainders form the answer, with the first remainder as the least significant bit (LSB) and the last as the most significant bit (MSB).

(43)10 = (101011)2

2 432 21 rem 1 LSB2 10 rem 12 5 rem 02 2 rem 12 1 rem 0

0 rem 1 MSB

REPEATED MULTIPLICATION-BY-2

To convert decimal fractions to binary, repeated multiplication by 2 is used, until the fractional product is 0 (or until the desired number of decimal places). The carried digits, or carries, produce the answer, with the first carry as the MSB, and the last as the LSB.

(0.3125)10 = (.0101)2

Carry0.31252=0.625 0 MSB

0.6252=1.25 1

0.252=0.50 0

0.52=1.00 1 LSB

Octal and Hexadecimal Numbers

1. Digital Systems2. Binary Numbers3. Number Base Conversions4. Octal and Hexadecimal Numbers5. Complements6. Signed Binary Numbers7. Binary Codes8. Binary Logic

BINARY TO OCTAL/HEXADECIMAL CONVERSION

• Binary Octal: partition in groups of 3(10 111 011 001 . 101 110)2 =

• Octal Binary: reverse(2731.56)8 =

• Binary Hexadecimal: partition in groups of 4

(101 1101 1001 . 1011 1000)2 = • Hexadecimal Binary: reverse

(5D9.B8)16 =

Complements

1. INFORMATION REPRESENTATION2. Binary Numbers3. Number Base Conversions4. Octal and Hexadecimal Numbers5. Complements6. Signed Binary Numbers7. Binary Codes8. Binary Logic

COMPLEMENTS•Complements are used in digital computers for simplifying the subtraction operation and for logical manipulation.

1. The radix complement ----- Given a number N in base-r having n digits, the r’s complement of N: rn - N, for N≠0

0, for N=0

2. The diminished radix complement. ----- Given a number Nin base-r having n digits, the (r-1)’s complement of N : (rn-1) -N

1’s and 2’s Complements The 2's complement and l's complement for binary numbers. 1’s complement of N = (2n-1) –N (N is a binary #) 1’s complement can be formed by changing 1’s to 0’s and 0’s to 1’s. 2’s complement of a number is obtained by leaving all least significant 0’s and the first unchanged, and replacing 1’s with 0’s and 0’s with 1 in all higher significant digits. The 1’s complement of 1101011 = 0010100 The 2’s complement of 0110111 = 1001001

9’s and 10’s Complements

10's complement and 9's complement are for decimal numbers.

The 9’s complement of546700 is 999999 -546700 = 453299

10’s (r’s) complement of decimal 23897610 (9’s complement) +1= 7611

Subtraction Using Complements

•Add the minuend, M, to the r’s complement of subtrahend, N. This performs M + (rn-N) = M- N + rn

•If M≥N, the sum will produce an end carry, rn, which can be discarded; what is left is the result M-N.

•If M<N, the sum does not produce an end carry and is equal to rn-(N-M), which is the r’s complement of (N-M). To obtain the answer in a familiar form, take the r’s comp of the sum and place a negative sign in front.

A = 1010100

2’s complement of B = + 0111101

Sum = 10010001

end carryDiscard end carry = – 10000000

Answer = 0010001

Subtract 1010100 – 1000011 using 2’s complement.

SIGNED BINARY NUMBERS

1. INFORMATION REPRESENTATION2. Binary Numbers3. Number Base Conversions4. Octal and Hexadecimal Numbers5. Complements6. Signed Binary Numbers7. Binary Codes8. Binary Logic

SIGNED BINARY NUMBERS

Unsigned numbers: only non-negative values.Signed numbers: include all values (positive and negative)The sign is represented by a ‘sign bit’0 for ‘+’ 1 for ‘-’E.g : a 1-bit sign and 7-bit magnitude format.

sign magnitude

00110100 +1101002 = +5210 10010011 -100112 = -1910

BINARY CODES1. INFORMATION REPRESENTATION2. Binary Numbers3. Number Base Conversions4. Octal and Hexadecimal Numbers5. Complements6. Signed Binary Numbers7. Binary Codes8. Binary Logic

BINARY CODES

Decimal Digit BCD8421

Excess-3 84-2-1 2*421 Biquinary5043210

0 0000 0011 0000 0000 01000011 0001 0100 0111 0001 01000102 0010 0101 0110 0010 01001003 0011 0110 0101 0011 01010004 0100 0111 0100 0100 01100005 0101 1000 1011 1011 10000016 0110 1001 1010 1100 10000107 0111 1010 1001 1101 10001008 1000 1011 1000 1110 10010009 1001 1100 1111 1111 1010000