260 likes | 565 Views
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.
E N D
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 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
Arithmetic Addition with Comparison Arithmetic Addition 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) = -(38 - 25) = -13
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).
Arithmetic Addition without Comparison 06 00000110 06 11111010 13 00001101 13 00001101 19 00010011 07 00000111 06 00000110 06 11111010 13 11110011 13 11110011 07 11111001 19 11101101 6
Arithmetic Subtraction (+/-) A – (+B)= (+/-) A + (-B) (+/-) A – (-B)= (+/-) A + (+B) Example (-6) – (-13)= +7 In binary: (1111010 – 11110011)= (1111010 + 00001101) =100000111 after removing the carry out the result will be : 00000111
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 3 - 148 + 576
BCD Addition Example : Evaluate the following operations in BCD System 1 – 3 + 4 2 – 4 + 8 3 - 148 + 576 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 3 - 184 + 576
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) = + 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
Decimal Arithmetic • Subtraction for signed and unsigned numbers • Apply 10‘s complement to the subtrahend and apply addition (same as binary case)
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
ASCII character code ASCII : American Standard Codefor Information Interchange ASCII code is used to represent characters , Symbols , … ASCII code consists of 7-bits (to represent 128 character) 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 1000001 01000001 11000001 ASCII T 1010100 11010100 01010100
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