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 http://www.wescottdesign.com I'm looking for work -- see my website!
Anyone use 1's compliment or signed magnitude?
Started by ●January 25, 2017
Reply by ●January 25, 20172017-01-25
On 1/24/2017 11:44 PM, Tim Wescott wrote:> 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?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
Reply by ●January 25, 20172017-01-25
On Wednesday, January 25, 2017 at 3:14:39 PM UTC+10:30, Tim Wescott wrote:> This is kind of a survey; I need some perspective (possibly historical) >=20 > Are there any digital systems that you know of that use 1's compliment or==20> signed-magnitude number representation for technical reasons? =20 >=20 > Have you ever used it in the past? >=20Quote: "Some designers chose 1=E2=80=99s complement, where =E2=88=92n was obtained= from n by simply inverting all bits. Some chose 2=E2=80=99s complement, wh= ere =E2=88=92n is obtained by inverting all bits and then adding 1. The former has the drawback of featur= ing two forms for zero (0=E2=80=A60 and 1=E2=80=A61). 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=E2=80=A61 as a negative number, making comparisons unnecessarily compl= icated. This case of inadequate design reveals 1=E2=80=99s complement as a = bad idea. Today, all computers use 2=E2=80=99s complement arithmetic." Ref: "Good Ideas, Through the Looking Glass" Niklaus Wirth, IEEE Computer. = Issue No. 01 - January (2006 vol. 39). https://www.computer.org/csdl/mags/co/2006/01/r1028-abs.html
Reply by ●January 25, 20172017-01-25
Tim Wescott wrote:> 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. >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
Reply by ●January 25, 20172017-01-25
Tim Wescott wrote:> 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? >The LINC computer used 1's complement. Having two zeros that did not compare as equal was a pain! Jon
Reply by ●January 25, 20172017-01-25
On Wed, 25 Jan 2017 02:59:46 -0800, cfbsoftware wrote:> On Wednesday, January 25, 2017 at 3:14:39 PM UTC+10:30, Tim Wescott > wrote: >> 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? >> >> > Quote: > > "Some designers chose 1’s complement, where −n was obtained from n by > simply inverting all bits. Some chose 2’s complement, where −n is > obtained by inverting all bits and then adding 1. The former has the > drawback of featuring two forms for zero (0…0 and 1…1). This is nasty, > particularly if available comparison instructions are inadequate. For > example, the CDC 6000 computers had an instruction that tested for zero, > recognizing both forms correctly, but also an instruction that tested > the sign bit only, classifying 1…1 as a negative number, making > comparisons unnecessarily complicated. 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). > > https://www.computer.org/csdl/mags/co/2006/01/r1028-abs.htmlI'm looking for current practice, not history. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com I'm looking for work -- see my website!
Reply by ●January 25, 20172017-01-25
On 1/25/2017 8:14 PM, Tim Wescott wrote:> On Wed, 25 Jan 2017 02:59:46 -0800, cfbsoftware wrote: > >> On Wednesday, January 25, 2017 at 3:14:39 PM UTC+10:30, Tim Wescott >> wrote: >>> 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? >>> >>> >> Quote: >> >> "Some designers chose 1’s complement, where −n was obtained from n by >> simply inverting all bits. Some chose 2’s complement, where −n is >> obtained by inverting all bits and then adding 1. The former has the >> drawback of featuring two forms for zero (0…0 and 1…1). This is nasty, >> particularly if available comparison instructions are inadequate. For >> example, the CDC 6000 computers had an instruction that tested for zero, >> recognizing both forms correctly, but also an instruction that tested >> the sign bit only, classifying 1…1 as a negative number, making >> comparisons unnecessarily complicated. 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). >> >> https://www.computer.org/csdl/mags/co/2006/01/r1028-abs.html > > I'm looking for current practice, not history.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
Reply by ●January 26, 20172017-01-26
On 01/24/2017 09:44 PM, Tim Wescott wrote:> 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. >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
Reply by ●January 26, 20172017-01-26
On 1/25/2017 11:50 PM, BobH wrote:> On 01/24/2017 09:44 PM, Tim Wescott wrote: >> 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. >> > > 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.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
Reply by ●January 26, 20172017-01-26
On Tue, 24 Jan 2017 22:44:32 -0600, Tim Wescott wrote:> 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 complimentor> 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?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