Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there any non-twos-complement implementations of C?

As we all no doubt know, the ISO C standard (and C++ as well, I think, though I'm more interested on the C side) allows three underlying representations of signed numbers:

  • two's complement;
  • ones' complement; and
  • sign/magnitude.

Wikipedia's entry states that sign/magnitude is used on the IBM 7090 from the 60s, and that ones' complement is used by the PDP-1, CDC 160A and UNIVAC 1100, all of which date back to the 60s as well.

Are there any other implementations of C (or underlying hardware) with these alternative representations, that have come out a little more recently than fifty years ago (and what are they)?

It seems a little wasteful to keep something in a standard for machines no longer in existence.

like image 346
paxdiablo Avatar asked Sep 05 '12 07:09

paxdiablo


People also ask

Does C use two's complement?

C and C++ as specified, however, are not two's complement. Signed integers currently allow the existence of an extraordinary value which traps, extra padding bits, integral negative zero, and introduce undefined behavior and implementation-defined behavior for the sake of this extremely abstract machine.

Do all computers use twos complement?

So if your bytes are more than 3 bits long, 100 will always be 8, not -4. Not every computer uses two's complement technically speaking, but it is very rare to find one that doesn't these days.

Why do many computers use a 2's complement representation of negative numbers?

Another method of representing signed numbers is two's complement. Most computers use this method to represent negative numbers. This method can be more effective when performing mathematical operations like adding and subtracting.


1 Answers

The most recent example I can find is the UNISYS 2200 series, based on UNIVAC, with ones-complement arithmetic. The various models were produced between 1986 and 1997 but the OS was still in active development as late as 2015. They also had a C compiler, as seen here.

It seems likely that they may still be in use today.

like image 52
Mike Seymour Avatar answered Oct 04 '22 07:10

Mike Seymour