Anyone use 1's compliment or signed magnitude?

• posted
This is kind of a survey; I need some perspective (possibly historical)
Are there any digital systems that you know of that use 1's compliment or
signed-magnitude number representation for technical reasons?
Have you ever used it in the past?
Is the world down to legacy applications and interfacing with legacy
sensors?
TIA.
```--
Tim Wescott
Wescott Design Services ```
• posted
Not sure I can be of a lot of help, but I do know these have been used in various systems in the past. 1's compliment has an advantage of not needing an adder to negate a number. in 1's compliment the negative is just all bits inverted. So some of the early computers used it for that reason. Addition is slightly complicated, or I should say subtraction since you must add a one to make the result come out right. Not a big deal as you can use the carry input to the lsb. Then there is the issue of having two zeros, 000...0 and 111...1 are both zero. lol
I have seen sign magnitude used in ADCs. I believe in some designs it is simpler to produce a magnitude and then just append a sign bit rather than adding the logic to create a two's complement number. In the old days the analog technology didn't lend itself to the logic so well. Otherwise I have not seen sign magnitude used anywhere or in any computers.
In some of the rather old business computers they used various forms of BCD or excess 3 code to simplify arithmetic since converting between binary and decimal digits can be a fair amount of work when you don't have fancy hardware.
```--

Rick C```
• posted
Quote:
"Some designers chose 1?s complement, where ?n was obtained from n by simply inverting all bits. Some chose 2?s complement, wh ere ?n is obtained by inverting all bits and then adding 1. The former has the drawback of featur ing two forms for zero (0?0 and 1?1). This is nasty, partic ularly if available comparison instructions are inadequate. For example, th e CDC 6000 computers had an instruction that tested for zero, recognizing b oth forms correctly, but also an instruction that tested the sign bit only, classifyi ng 1?1 as a negative number, making comparisons unnecessarily compl icated. This case of inadequate design reveals 1?s complement as a bad idea. Today, all computers use 2?s complement arithmetic."
Ref: "Good Ideas, Through the Looking Glass" Niklaus Wirth, IEEE Computer. Issue No. 01 - January (2006 vol. 39).

• posted
If by "signed-magnitude" you mean "sign-magnitude", i.e. numbers are always positive binary encoding with a separate sign bit, then most floating point formats use it for the mantissa. Once again you have the possibility of positive and negative zero, however IEEE floating formats don't allow negative zero in the standard encoding, so you need to check for zero when negating a number. Zero is a special case in these formats, because otherwise there is an assumed 1 to the left of the mantissa. The same formats use offset binary for the exponent.
```--
Gabor```
• posted
The LINC computer used 1's complement. Having two zeros that did not compare as equal was a pain!
Jon
• posted
I'm looking for current practice, not history.
```--
Tim Wescott
Wescott Design Services ```
• posted
Other than the few ADC parts I described that use sign-magnitude, I'm pretty sure you won't find any computers using either 1's complement or sign-magnitude. Pocket calculators likely still use BCD. Otherwise everything is 2's complement binary.
```--

Rick C```
• posted
I have done hardware dividers and multipliers that only work with positive integers, so you have to convert to positive values and track the sign externally. This qualifies as sign magnitude, I think.
Also, working in mixed analog/digital systems, sign magnitude is pretty common at the analog/digital boundary. The analog part accepts a magnitude value and a sign bit. Think about a simple R2R DAC and an analog transmission gate for accepting the true or inverted value. 2's complement takes extra work to accept.
BobH
• posted
I don't agree. 2's compliment to a DAC only requires the sign bit to be inverted (same as offsetting by 2**(n-1)) and that the range of the DAC output be biased so the original zero value is at zero volts if that is what is desired.
I have seldom seen available analog conversion parts use sign magnitude, but they do exist.
```--

Rick C```
• posted
or
Every time you surf the web you use 1's comp arithmetic for the IP and TCP header checksum calculations. That's just what the spec says. I'm sure someone at one time thought it had some technical advantage over other sorts of checksums, but it's actually quite poor in terms of its error detection capabilities and isn't that fast to calculate.
In two different jobs I've designed FPGA-based systems that would alter a field in the IP or TCP header then adjust the checksum to suit rather than recalculating it from scratch. This requires a firm knowledge of 1's comp arithmetic, e.g. you need to know that the +0 and -0 aren't equivalent in this context.
As an aside, I once used an HP Ethernet switch didn't do it correctly and would corrupt non-IP frames that happened to have particular values (IIRC it was 0000 or ffff) in the same position as the IP checksum field in the packet header.
There are multiple RFCs describing how it's done. Some of them are even correct.
Regards, Allan
• posted
The ones-complement sum of the 16-bits words is invariant with respect to byte swapping. That is, it just works on either big-endian or little- endian machines. I've never read anything saying that's why they chose it but it's what I've always suspected.
• posted
?????
• posted
These are not customer visible interfaces Rick. These are trim DACs used for part parameter trimming that the customer never sees or even knows that they exist. I spent the last 7 years dealing with this at a couple of large semiconductor houses.
BobH
• posted
What does "customer visible" have to do with it? You seem to be talking about rolling your own DAC using a bunch of I/O pins and resistors with analog inversion circuitry after. I'm explaining how it can be done more easily. If you don't need bipolar outputs, why do you need negative binary values at all?
I've said there are a few sign magnitude DAC parts out there, but not so many. I can't recall ever using one.
```--

Rick C```
• posted
My understanding of Bob's post here is that the "customer" in this case is the hardware design that is buying the chip, not the end-user or even the board's programmer. So when you buy an ADC with a precision 2.5V internal reference, Bob is talking about the trim DAC that is factory calibrated to modify the base reference - /you/ are the customer for whom this interface is invisible.
• posted
Well, ther's TCP/ip checksums
• posted
Snip
"Not customer visible" means that the person that buys one of these parts to stick on a board is un-aware of the interface between the internal digital logic and internal analog circuitry. The people designing the analog guts of a mixed signal chip do "roll their own" DACs in several flavors. Unless you work in mixed signal IC design or test, you would never see these interfaces. For a DAC or ADC product, "customer visible" has a lot to do with it because people want 2's complement or biased binary at the system interface so that it plays nice with the arithmetic in the rest of the system or doesn't confuse the firmware people. For internals of a chip, as a digital design engineer or test engineer, you just deal with it. As for why it is done the way it is, I am not completely sure, it is just what analog designers do.
Even fairly analog seeming components like the voltage reference that David mentioned generally have a digital section with flash or OTP memory that gets read at power up and sets DACs used to configure the reference output to the 1% or whatever the part spec is. Bandgaps have 3 or 4 analog parameters effecting output voltage and output flatness over temperature that need to be set. As part of final test on the silicon die, they measure the device performance and set the values in the memory. This allows the manufacturer to correct for process variations and uniformity issues across a wafer the size of a dinner plate. When you see "NC" pins on small analog devices, they are often used for the access to these memories. The actual signalling methods are pretty closely held and not something a customer is likely to stumble on.
The "I/O pins" in use are interconnects between the digital block and the analog section on the die. The last chip that I worked on had 100+ digital signals crossing the analog/digital boundary. Some were control signals and some were trim signals. I think that there were 5 or 6 parallel interfaced DACs from 4 bits to 11 bits. Of those, 2 or 3 used sign magnitude format to pass the trim information across.
BobH
• posted
1's complement is nearly the very definition of history as implied by "Have you ever used it in the past?"
The only machine I am aware used 1's complement is a 1970's mainframe.
I have not been aware of any since, its a daft idea.
```--
Mike Perkins
Video Solutions Ltd ```
• posted
I've used sign-magnitude for some compression schemes, in which case the sign bit takes the least significant place. 10 = -1 11 = +1 100 = -2 101 = +2 110 = -3 111 = +3 1000 = -4 ...

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.