snowfox
snowfox

Reputation: 2098

Why is Two's complement being used more widely in preference to Ones' complement in representation of signed numbers

The latter representation looks more natural to understand. Why do most languages choose the former one? I guess there must be some unique and thus advantageous characteristics in the Two's complement which make data operations easier.

Upvotes: 3

Views: 983

Answers (2)

geekosaur
geekosaur

Reputation: 61369

Languages don't specify the number format; the hardware does. Ask Intel why they designed their ALU to do 2's complement

The answer will be because the mathematical operations are more regular in 2s complement; positive and negative numbers need to be handled differently in 1s complement, which means double the hardware/microcode needed for basic math in the CPU.

Upvotes: 5

taskinoor
taskinoor

Reputation: 46027

From Wikipedia

The two's-complement system has the advantage that the fundamental arithmetical operations of addition, subtraction and multiplication are identical, regardless of whether the inputs and outputs are interpreted as unsigned binary numbers or two's complement (provided that overflow is ignored). 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.

Upvotes: 4

Related Questions