1. binary system

25
1 1. Binary System

Upload: nell-henson

Post on 04-Jan-2016

57 views

Category:

Documents


3 download

DESCRIPTION

1. Binary System. Binary Number. a 5 a 4 a 3 a 2 a 1 a 0 .a -1 a -2 a -3 = a n r n +a n-1 r n-1 +...+a 2 r 2 +a 1 r+a 0 +a -1 r -1 +a -2 r -2 +...+a -m r -m 7392 = 7 × 10 3 + 3 × 10 2 + 9 × 10 1 +2 × 10 0 (11010.11) 2 = 1×2 4 +1×2 3 +0×2 2 +1×2 1 +0×2 0 +1×2 -1 +1×2 -2 - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: 1. Binary System

1

1. Binary System

Page 2: 1. Binary System

2

Binary Number a5a4a3a2a1a0.a-1a-2a-3

= anrn+an-1rn-1+...+a2r2+a1r+a0+a-1r-1+a-2r-2+...+a-mr-m

7392 = 7 × 103 + 3 × 102 + 9 × 101 +2 × 100 (11010.11)2 =1×24+1×23+0×22+1×21+0×20+1×2-1+1×2-2

= (26.75)10

210

220

230

= 1Kilo

= 1Mega= 1Giga

2n2n2n

Page 3: 1. Binary System

3

Augend 101101 Minuend: 101101 Multiplicand:

1011

Addend +100111 Subtrahend:

-100111 Multiplier: *101

sum 1010100 Difference: 000110 1011

0000

1011

Product: 110111

Binary Number

Page 4: 1. Binary System

4

Number Base Conversions Ex 1-1) Convert decimal 41 to binary.

answer : (41)10 = (a5a4a3a2a1a0)2 = (101001)2

IntegerQuotient

Remainder Coefficient

41/2 = 20 + ½ a0 = 1

20/2 = 10 + 0 a1 = 0

10/2 = 5 + 0 a2 = 0

5/2 = 2 + ½ a3 = 1

2/2 = 1 + 0 a4 = 0

1/2 = 0 + ½ a5 = 1

Integer Remainder

41

20 1

10 0

5 0

2 1

1 0

0 1

Answer

=101001

Page 5: 1. Binary System

5

Ex 1-2) Convert decimal 153 to octal.

Ex 1-3) Convert (0.6875)10 to binary.

Number Base Conversions

153

19 1

2 3

0 2 = (231)8

Integer Fraction Coefficient

0.6875*2 = 1 + 0.3750 a-1 = 1

0.3750*2 = 0 + 0.7500 a-2 = 0

0.7500*2 = 1 + 0.5000 a-3 = 1

0.5000*2 = 1 + 0.0000 a-4 = 1

Answer:(0.6875)10 = (0.a-1a-2a-3a-4)2 = (0.1011)2

Ex 1-4) 해보세요 .

Page 6: 1. Binary System

6

Octal and Hexadecimal Numbers

( 10  110  001  101  011  .  111  100  000  110 )2 = (26153.7460)8

                  2    6    1     5    3       7    4   0    6

( 10  1100  0110  1011  .  1111  0010 )2 = (2C6B.F2)16

                  2    C      6     B        F      2 * PC 의 계산기 기능

Page 7: 1. Binary System

7

(r-1)’s complements of an n-digit N is (rn-1)-N r=10, r-1=9, 9’complements of N is (10n-1)-N Ex) the 9’s complements of 546700 is 999999-546700 = 453299

the 9’s complements of 012398 is 999999-012398 = 987601

For binary number, r=2, r-1=1 1’complements of N is (2n-1)-N Ex) the 1’s complements of 1011000 is 0100111

the 1’s complements of 0101101 is 1010010

Complements – Diminished Radix Complement

Page 8: 1. Binary System

8

The r’s complements of an n-digit number N is rn-N, N≠0 0, N=0 rn-N=[(rn-1)-N]+1 => The r’s complements is obtained by adding 1 to the (r-1)’s complements

Ex) The 10’s complements of 012398 is 987602 The 10’s complements of 246700 is 753300

The 2’s complements of 1101100 is 0010100 The 2’s complements of 0110111 is 1001001

Ex) The 10’s complements and 9’s complements of 086632 ? The 2’s complements and 1’s complements of 0110101 ?

• 1’s complement 와 2’s complement 중 어느쪽이 계산 편리 ?• CPU 는 (-) 연산 기능 없슴 (+) 과 complement 기능으로 (-) 연산

수행

Complements – Radix Complement

Page 9: 1. Binary System

9

Ex1-5) using 10’s complement, subtract 72532-3250. 72532 + (100000-3250) : carry 발생

Ex1-6) Using 10’s complement, subtract 3250-72532. 3250 -72532+100000 = 3250 + (100000-72532) : no carry

There is no end carry Therefore, the answer is –(10’s complement of 30718)=-

69282

Complements – Subtraction with Complements

M = 72532

10’s complement of N = + 96750

Sum = 169282

Discard end carry 105 = -100000

Answer = 69282

M = 03250

10’s complement of N = +27468

Sum = 30718

Page 10: 1. Binary System

10

Ex1-7) X=1010100, Y=1000011, (a) X-Y, (b) Y-X

Complements – Subtraction with Complements

X = 1010100

2’s complement of Y = +0111101

Sum = 10010001

Discard end carry 27 = -10000000

Answer: X-Y = 0010001

Y = 1000011

2’s complement of X = +0101100

Sum = 1101111

(a) X-Y

(b) Y-X

There is no carry.

The answer is Y-X = -(2’s complement of 1101111)=-0010001

Page 11: 1. Binary System

11

Ex1-8) Repeat Example 1-7 using 1’complement.

Complements – Subtraction with Complements

(a) X-Y = 1010100-1000011X = 1010100

1’s complement of Y = +0111100

Sum = 10010000

End-around carry = + 1

Answer: X-Y = 0010001

(b) Y-X = 1000011-1010100

Y = 1000011

1’s complement of X = +0101011

Sum = 1101110There is no carry.

The answer is Y-X = -(1’s complement of 1101110)=-0010001

Page 12: 1. Binary System

12

Signed Binary Numbers Ex) 8bit 로서 나타낼 수 있는 숫자 : 0-255 ( 모두 양수인경우 ). 만약 반은

음수 , 반은 양수로 나타내고 싶을 때의 방법은 ? ( 즉 -127 ~ +127(8) 로 나태 내고 싶을 때의 방법은 ?)

Ex) The number 9 represented in binary with eight bit

+9 : 00001001

-9 : 10001001 (signed-magnitude representation) 11110110 (signed-1’s-complement representation) 11110111 (signed-2’s-complement representation) Complement 의 complement 는 원래의 수가 됨 덧셈 , 뺄셈의 결과가 모순이 없고 , 편리하게 되는지의 여부

Page 13: 1. Binary System

13

Signed Binary Numbers

Page 14: 1. Binary System

14

Arithmetic Addition - signed-magnitude system follows the rules of ordinary arithmetic.

- 같은 부호의 경우 : 덧셈후 해당 부호 부여 – 예 : …- 다른 부호의 경우 : 큰 수에서 작은 수를 뺀 후 큰 수의 부호를 부여 -예 :..

- signed-complement system requires only addition (no deed of subtraction) – 2’s complement 의 경우 (carry 는 discard).

Arithmetic Subtraction(±A)-(+B) = (±A)+(-B) (±A)-(-B) = (±A)+(+B)

Overflow 문제 : paper 에서는 자리수를 증가하여 해결가능하나 , 컴퓨터 시스템에서는 제한된 bit 길이 고려하여야 함

Signed Binary Numbers

+6 00000110 -6 11111010

+13 00001101 +13 00001101

+19 00010011 +7 00000111

+6 00000110 -6 11111010

-13 11110011 -13 11110011

-7 11111001 -19 11101101

Page 15: 1. Binary System

15

000 0 0001 1 1010 2 2011 3 3100 4 -4101 5 -3110 6 -2111 7 -1

Arithmetic Addition 의 예 (2’s complement)

+1 001 +1 001

+2 010 -3 101

+3 011 -2 110

-1 111 -1 111

+3 011 -2 110

+2 1 010 -3 1 101

-4 ~ 3 안에서의 결과가 나오는 연산은 O.K.

Page 16: 1. Binary System

16

- the 4-bit code for one decimal (185)10 = (0001 1000 0101)BCD = (10111001)2

BCD Addition

- if the binary sum is greater or equal to 1010, we add 0110 to

obtain the correct BCD

Binary Code-BCD code

4 0100 4 0100 8 1000

+5 +0101 +8 +1000

+9 +1001

9 1001 12 1100 17 10001

+0110

+0110

10010 10111

Page 17: 1. Binary System

17

Binary Code-Other Decimal Codes

Excess-3 : BCD+3 임 , 9’complement 를 구할 때는 bit 의 1,0을 바꾸어주면 됨

2421 : 같은 숫자 2개의 코드 가능 , ex) 4 의 경우 0100, 1010 모두 가능

Page 18: 1. Binary System

18

예 ) 0100 을 다음의 형식대로 해석을 하면 얼마를 나타내는 수인가 ?

- BCD 8421 : 0X8 + 1X4 + 0X2 + 0X1 =4- 2421 : 0X2 + 1X4 + 0X2 + 0X1 = 4- Excess-3 : 4-3 = 1- 8 4 -2 -1 : 0X8 + 1X4 + 0X(-2) + 0X(-1) = 4

예 ) 1001 을 BCD 8421, Excess-3, (8 4 -2 -1) 의 형식으로 해석하면 각각 얼마를 나타내는 수인가 ?

예 ) 2421 코드에서 7 을 나타낼 수 있는 코드 2 개를 찾으시오 .

Binary Code-Other Decimal Codes

Page 19: 1. Binary System

19

Binary Code-Gray Code

연속적인 값에 1bit 만이 변함 , 아날로그 값 입력시의 오류나 애매함을 방지 . 즉 연속적인 값 입력시에 2bit 이상이 차이가 나면 오류임

예 ) 3 bit 의 gray code 를 design 하시오 .

Page 20: 1. Binary System

20

예 ) 3 bit 의 gray code 를 design 하시오 . 000 0001 1011 2010 3110 4111 5101 6100 7

Binary Code-Gray Code

Page 21: 1. Binary System

21

Binary Code- ASCII Character CodeA : 100 0001 = 0x41a : 110 0001 = 0x61DEL : 111 1111 = 0x7FSP : 010 0000 = 0x20

Page 22: 1. Binary System

22

Error-Detecting Code

With even parity With odd parity

ASCII A = 1000001 01000001 11000001

ASCII T = 1010100 11010100 01010100

Binary Code

Page 23: 1. Binary System

23

Registers – A register with n cells can store any discrete quantity of information that contains n bits.

Register Transfer

Binary Storage and Registers

Page 24: 1. Binary System

24

Binary Logic Definition of Binary Logic

Logic Gates

Page 25: 1. Binary System

25

Binary Logic