Presentation is loading. Please wait.

Presentation is loading. Please wait.

Negative Integers Unsigned binary representation can not be used to represent negative numbers. With paper and pencil arithmetic, a number is made negative.

Similar presentations


Presentation on theme: "Negative Integers Unsigned binary representation can not be used to represent negative numbers. With paper and pencil arithmetic, a number is made negative."— Presentation transcript:

1 Negative Integers Unsigned binary representation can not be used to represent negative numbers. With paper and pencil arithmetic, a number is made negative by putting a negative sign in front of it: 1410 negated = -1410 You might hope to do the same with binary: negated = Unfortunately, you can't put a negative sign in front of a bit pattern in computer memory. Memory holds only patterns of 0's and 1's.

2 Sign-Magnitude Representation
There are many schemes for representing negative integers with patterns of bits. One scheme is sign-magnitude. It uses one bit (usually leftmost) to indicate the sign. "0" indicates a positive integer and "1" indicates a negative integer. The rest of the bits are used for the magnitude of the number. So is represented as: last bits are magnitude The sign "1" means negative, ”0”-positive

3 Sign Magnitude Pros & Cons
Advantages: It works well for representing positive and negative integers. Disadvantages: One pattern corresponds to "minus zero", 1000 Another corresponds to "plus zero", Computations are not simple.

4 Sign magnitude calculations many sign and magnitude checks
If the signs are the same, it must add the magnitudes and give the result the same sign. If the signs are different, it must compare the magnitudes subtract the smaller from the larger and give the result the sign of the larger. All of these “ifs”, “adds”, “subtracts”, and “compares” translate into a lot of logic-circuit complexity. Adders for complement number systems are much simpler.

5 Sign magnitude vs Complements
While the signed-magnitude system negates a number by changing its sign a complement number system negates by taking its complement. In a Complement number system two numbers can be added or subtracted directly without the sign and magnitude checks.

6 One’s complement The negative numbers are represented by the patterns derived from the positive numbers. Adding the negative and positive numbers with the same absolute value results the pattern of all ones. Negative = 2N – 1 – Positive

7 One’s complement pros & cons
Advantages: In a Complement number system two numbers can be added or subtracted directly without the sign and magnitude checks. Disadvantages: Arithmetic still a somewhat complicated. Still two zeros 0x0000 = +0ten 0x1111 = -0ten Although used for a while on some computer products, one’s complement was eventually abandoned because another solution was better.


Download ppt "Negative Integers Unsigned binary representation can not be used to represent negative numbers. With paper and pencil arithmetic, a number is made negative."

Similar presentations


Ads by Google