1.6 signed binary numbers

24
1.6 Signed Binary Numbers

Upload: kaden-head

Post on 31-Dec-2015

214 views

Category:

Documents


13 download

DESCRIPTION

1.6 Signed Binary Numbers. 1.6 Signed Binary Numbers. 1 - Sign and Magnitude representation 2 - 1’s Complement Representation 3 - 2’s Complement Representation. Notes. 1 - The previous representation are the same for positive numbers and different for negative numbers. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: 1.6 Signed Binary Numbers

1.6 Signed Binary Numbers

Page 2: 1.6 Signed Binary Numbers

1.6 Signed Binary Numbers

1 - Sign and Magnitude representation

2 - 1’s Complement Representation

3 - 2’s Complement Representation

1 - The previous representation are the same for positive numbers and different for negative numbers

2 - For a signed binary number the most significant bit is used for representing the sign of the number

We use 0 for positive numbers and 1 for negative numbers

Notes

Example : represent +76

10 2

10 2

10 2

76 1001100 &

76 1001100 1'

0

76 1

0

0 001100 2 '

Sign Magnitude

s Complement

s Complement

Page 3: 1.6 Signed Binary Numbers

Representing negative numbers in the previous three systems

1’s Complement of a negative number can be obtained by flipping all bits of the positive binary number

2’s Complement of a negative number can be obtained by adding 1 to the 1’s Complement or by flipping bits of the positive binary number after the first one from the right

Example : represent -76

10 2

10 2

10 2

76 1001100 &

76 0110011 1'

1

76 0

1

1 110100 2 '

Sign Magnitude

s Complement

s Complement

Page 4: 1.6 Signed Binary Numbers

Arithmetic Addition with Comparison

The addition of two numbers in the signed mgnitude system follow the rules of ordinary arithmetic.

If the signed are the same, we add the two magnitudes and give the sum the common sign.

If the signed are different, we subtract the smaller magnitudefrom the larger and give the difference the sign of the largermagnitude. EX. (+25) + (-38) = -(38 - 25) = -13

Arithmetic Addition

Page 5: 1.6 Signed Binary Numbers

Arithmetic Addition without Comparison

The addition of two signed binary number with negative numbers represented in signed 2’s complement form is obtained from the addition of the two numbers, including their signed bits. A carry out of the signed bit position is discarded (note that the 4th case).

Page 6: 1.6 Signed Binary Numbers

Arithmetic Addition without Comparison

19 1110110113 1111001106 11111010

07 1111100113 1111001106 00000110

07 00000111

13 0000110106 11111010

19 00010011

13 0000110106 00000110

6

Page 7: 1.6 Signed Binary Numbers

Arithmetic Subtraction

(+/-) A – (+B)= (+/-) A + (-B) (+/-) A – (-B)= (+/-) A + (+B)

Example (-6) – (-13)= +7In binary: (1111010 – 11110011)= (1111010 +

00001101) =100000111 after removing the carry out the result will be : 00000111

Page 8: 1.6 Signed Binary Numbers

1.7 Binary Codes

Page 9: 1.6 Signed Binary Numbers

Binary Coded Decimal (BCD)

Page 10: 1.6 Signed Binary Numbers

Binary Coded Decimal (BCD)

in this system each digit is represented in 4 bits

For example : to represent in BCD

9 54

1001

10945

0100 0101

10 BCD10010100010 9 5 14

Page 11: 1.6 Signed Binary Numbers

BCD Addition

Example : Evaluate the following operations in BCD System

1 – 3 + 4

2 – 4 + 8

3 - 148 + 576

3 4

7

01000111

0011BCD BCD Decimal

Page 12: 1.6 Signed Binary Numbers

BCD Addition

Example : Evaluate the following operations in BCD System

1 – 3 + 4

2 – 4 + 8

3 - 148 + 576

4

8

12

10001100

0100BCD BCD

Decimal

Error

01100001001012

We must add 6 (0110) to the result

Page 13: 1.6 Signed Binary Numbers

BCD

BCD Addition

Example : Evaluate the following operations in BCD System

1 – 3 + 4

2 – 4 + 8

3 - 184 + 576

1846 57

1

0001BCD 1000 0100

0101 0111 0110

Decimal

0111 0000 1010

0110 0110

0111 0110 00001 1

1

760 1

760

Page 14: 1.6 Signed Binary Numbers

1 – In BCD Addition , we add (0110)=(6) if the result value was greater than (1001)=(9) or if the result was more than 4 digits

Notes

In previous Example we added 0110 when the result was

1 - greater than 9 (1001)

2 - more than 4 digits (10000)

Note : result more than 4 digit is greater than 9(1001)

Page 15: 1.6 Signed Binary Numbers

Decimal Arithmetic

Addition for signed numbers

Example: (+375) + (- 240) = + 135 in BCD

• Apply 10‘s complement to the negative number only.• Addition is done by summing all digits,including the sign

digit,and discarding the end carry 0 375 +9 760 ------------ 0 135

Page 16: 1.6 Signed Binary Numbers

Decimal Arithmetic

• Subtraction for signed and unsigned numbers

• Apply 10‘s complement to the subtrahend and apply addition (same as binary case)

Page 17: 1.6 Signed Binary Numbers

(ex-3) is like (BCD) in the way of representing number

i.e. each digit is represented in 4 bits

Except that : each digit is firstly incremented by three

Excess-3 (ex-3)Excess-three (ex-3)is another system to represent a number

For example : to represent in ex-3

12 87

1100

10945

0111 1000

10 311000111100 94 05

ex

9 54

Page 18: 1.6 Signed Binary Numbers
Page 19: 1.6 Signed Binary Numbers

Gray Code

Page 20: 1.6 Signed Binary Numbers

ASCII code is used to represent characters , Symbols , …

ASCII code consists of 7-bits (to represent 128 character)

ASCII character code

ASCII : American Standard Code for Information Interchange

Upper case Letters are represented by ASCII (65 : 90)

Lower case Letters are represented by ASCII (97 : 122)

# ASCII Ch

65 1000001 A

66 1000010 B

90 1011010 Z

97 1100001 a

98 1100010 b

122 1111001 z

Page 21: 1.6 Signed Binary Numbers
Page 22: 1.6 Signed Binary Numbers

Error Detecting Code

with even parity with odd parityASCII A 1000001 01000001 11000001ASCII T 1010100 11010100 01010100

Page 23: 1.6 Signed Binary Numbers
Page 24: 1.6 Signed Binary Numbers

For more information about Number Systems and Conversations between them

Check these

1 – Our Logic Book

2 - Computer Organization's Lectures

3 – Any other References