开发者

When would I use twos, ones, or just signed?

If I want -3 in bin开发者_开发技巧ary, I can use signed bit, or ones complement, or two's complement, correct?

However, when is it appropriate to use a method? and why?

Let's just use 8 bits:

-3 with signed is just 10000011

-3 with ones is just 11111100

-3 with twos is just 11111101


Wikipedia neatly summarizes the benefits of two's complement:

The two's-complement system has the advantage of not requiring that the addition and subtraction circuitry examine the signs of the operands to determine whether to add or subtract. This property makes the system both simpler to implement and capable of easily handling higher precision arithmetic. Also, zero has only a single representation, obviating the subtleties associated with negative zero, which exists in ones'-complement systems.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜