Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter3 Fixed Point Representation

Similar presentations


Presentation on theme: "Chapter3 Fixed Point Representation"— Presentation transcript:

1 Chapter3 Fixed Point Representation
Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2009

2 Subtract by Summation Subtraction with complement is done with binary numbers in a similar way. Using two binary numbers X= and Y= We perform X-Y and Y-X

3 X-Y X= 2’s com. of Y= Sum= Answer=

4 Y-X Y= 2’s com. of X= Sum= There’s no end carry: answer is negative (2’s complement of )

5 How To Represent Signed Numbers
Plus and minus signs used for decimal numbers: (or +25), -16, etc. For computers, it is desirable to represent everything as bits. Three types of signed binary number representations: signed magnitude, 1’s complement, and 2’s complement

6 1. signed magnitude In each case: left-most bit indicates sign: positive (0) or negative (1). Consider 1. signed magnitude: = 1210 Sign bit Magnitude = Sign bit Magnitude

7 2. One’s Complement Representation
The one’s complement of a binary number involves inverting all bits. To find negative of 1’s complement number take the 1’s complement of whole number including the sign bit. = 1210 Sign bit Magnitude = Sign bit 1’complement

8 3. Two’s Complement Representation
The two’s complement of a binary number involves inverting all bits and adding 1. To find the negative of a signed number take the 2’s the 2’s complement of the positive number including the sign bit. = 1210 Sign bit Magnitude = Sign bit 2’s complement

9 Sign addition in 2’s complement
The rule for addition is add the two numbers, including their sign bits, and discard any carry out of the sign (leftmost) bit position. Numerical examples for addition are shown below. Example: In each of the four cases, the operation performed is always addition, including the sign bits. Only one rule for addition, no separate treatment of subtraction. Negative numbers are always represented in 2’s complement. 9

10 Arithmetic Subtraction
A subtraction operation can be changed to an addition operation if the sign of the subtrahend is changed. (±A) - (+B) = (±A) + (-B) (±A) - (-B) = (±A) + (+B)

11 Arithmetic Subtraction
Consider the subtraction of (-6) - (-13) = +7. In binary with eight bits this is written as The subtraction is changed to addition by taking the 2’s complement of the subtrahend (-13) to give (+13). In binary this is = Removing the end carry, we obtain the correct answer (+ 7).

12 Overflow The detection of an overflow after the addition of two binary numbers depends on whether the considered numbers are signed or unsigned. When two unsigned numbers are added, an overflow is detected from the end carry out of the most significant position. In the case of signed numbers, the leftmost bit always represents the sign, and negative numbers are in 2’s complement form. When two signed numbers are added, the sign bit is treated as part of the number and the end carry does not indicate an overflow.

13 Overflow Overflow example: +70 0 1000110 -70 1 0111010
= =

14 Overflow An overflow cannot occur after an addition if one number is positive and the other is negative, since adding a positive number to a negative number produces a result that is smaller than the larger of the two original numbers. An overflow may occur if the two numbers added are both either positive or negative.

15 Floating-Point Representation
is represented in floating-point with a fraction and an exponent as follows: Fraction Exponent Scientific notation :  10+4

16 Floating-Point Representation
Floating point is always interpreted as: m  re Floating point binary number uses base 2 for the exponent. For example: Binary number Fraction(8 bits) Exponent (6 bits) The fraction has a 0 in the leftmost position to denote positive. m  2e = + ( )2  2+4

17 Floating-Point Representation
A floating-point number is said to be normalized if the most significant digit of the mantissa is nonzero. For example: (1)   350 is normalized but is not. (2)   The 8-bit binary number is not. It can be normalized by shifting to obtain The three shifts multiply the number by 23=8. To keep the same value for floating-point number, the exponent must be subtracted by 3.

18 Floating-Point Representation
32-bit floating point format. Leftmost bit = sign bit (0 positive or 1 negative). Exponent in the next 8 bits. Use a biased representation. Final portion of word (23 bits in this example) is the significand (sometimes called mantissa).

19 Example sign sign EXP EXP Significant
Convert the following number; into floating point format to fit in 32 bit register. Convert the number from decimal into binary Normalize all digits including the fraction to determine the exponent. x 25 1 sign sign EXP EXP Significant


Download ppt "Chapter3 Fixed Point Representation"

Similar presentations


Ads by Google