1.6 Signed Binary Numbers.

Presentation on theme: "1.6 Signed Binary Numbers."— Presentation transcript:

1.6 Signed Binary Numbers

1.6 Signed Binary Numbers Example : represent +76 Notes
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 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 Example : represent +76

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

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 magnitude from the larger and give the difference the sign of the larger magnitude. EX. (+25) + (-38) = -( ) = -13

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).

6

Arithmetic Subtraction
(+/-) A – (+B)= (+/-) A + (-B) (+/-) A – (-B)= (+/-) A + (+B) Example (-6) – (-13)= +7 In binary: ( – )= ( ) = after removing the carry out the result will be :

1.7 Binary Codes

Binary Coded Decimal (BCD)

Binary Coded Decimal (BCD)
in this system each digit is represented in 4 bits For example : to represent in BCD

BCD Addition Example : Evaluate the following operations in BCD System
1 – 3 + 4 2 – 4 + 8

BCD Addition Example : Evaluate the following operations in BCD System
1 – 3 + 4 2 – 4 + 8 Error We must add 6 (0110) to the result

BCD Addition Example : Evaluate the following operations in BCD System
1 – 3 + 4 2 – 4 + 8

In previous Example we added 0110 when the result was
Notes 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 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) 

Decimal Arithmetic Addition for signed numbers
Example: (+375) + (- 240) = 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

Decimal Arithmetic Subtraction for signed and unsigned numbers
Apply 10‘s complement to the subtrahend and apply addition (same as binary case)

For example : to represent in ex-3
Excess-3 (ex-3) Excess-three (ex-3)is another system to represent a number (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 For example : to represent in ex-3

Gray Code

ASCII character code ASCII : American Standard Code for Information Interchange ASCII code is used to represent characters , Symbols , … ASCII code consists of 7-bits (to represent 128 character) # ASCII Ch 65 A 66 B 90 Z 97 a 98 b 122 z Upper case Letters are represented by ASCII (65 : 90) Lower case Letters are represented by ASCII (97 : 122)

Error Detecting Code with even parity with odd parity
ASCII A ASCII T