-1
\$\begingroup\$

I wanted to know about the advantages of 1's complement over 2's complement in DSP applications.

\$\endgroup\$
6
  • 2
    \$\begingroup\$ Did you read https://en.m.wikipedia.org/wiki/Ones%27_complement? \$\endgroup\$ Jun 19, 2017 at 6:35
  • \$\begingroup\$ Yes I did read it. \$\endgroup\$ Jun 19, 2017 at 7:30
  • \$\begingroup\$ Can you please elaborate what you want to say sir? \$\endgroup\$ Jun 19, 2017 at 8:11
  • 1
    \$\begingroup\$ We have no way of knowing what kind of "major reason" you're after. Closing as unclear. \$\endgroup\$ Jun 19, 2017 at 10:54
  • \$\begingroup\$ One's complement has one advantage: it works regardless of endianness. That's why it's used in calculating TCP header checksum. Unfortunately this was closed so I can't post a more detailed answer \$\endgroup\$
    – phuclv
    Aug 7, 2018 at 8:21

1 Answer 1

4
\$\begingroup\$

In 1's complement, changing sign can't fail, contrary to 2's complement. This mimics Floating Point, and remove one (minor) headache when moving FP algorithms with fixed point arithmetic, a common thing with DSPs.

To be clear: with 1's complement, it holds that if x<0 then (-x)>0, something that holds for FP but does not hold for quite all x with 2's complement, and easily bites when doing digital signal processing. DSPs aim at FP compatibility for their non-FP operations, and avoiding that corner case has some functional value.

Also: changing sign in 1's-complement reduces to complementing all bits; and thus, as noted in comment, it is endian-neutral. By contrast, changing sign in 2's complement requires carry propagation from low-order to higher-order chunks (byte, word, unamit).

I know no better reasons. Most other things (including signed addition and multiplication) are easier with 2's complement: in particular, the result (except status bits) is the same as for unsigned. That's why it won for the non-FP part of most modern processors, which support both signed and unsigned.

\$\endgroup\$
3
  • \$\begingroup\$ I need a major reason sir. \$\endgroup\$ Jun 19, 2017 at 7:31
  • 2
    \$\begingroup\$ That is a good reason. Why do you need a "major reason"? \$\endgroup\$
    – Oskar Skog
    Jun 19, 2017 at 20:39
  • 1
    \$\begingroup\$ I don't know the advantage in DSP but it has an advantage in network transmission because it doesn't depend on endianness, therefore it's used in TCP header checksum \$\endgroup\$
    – phuclv
    Aug 7, 2018 at 8:23

Not the answer you're looking for? Browse other questions tagged or ask your own question.