News for hackers. Stuff that matters.
Re:Signed Integers Are Two’s Complement by 0xcde4c3db on Wednesday May 30, 2018 @10:52PM (#17193603)
It can be useful to distinguish between positive and negative zero in some cases, for example when dealing with values that have been rounded to zero or limits approaching zero.
Re:Signed Integers Are Two’s Complement by daveFNbuck on Thursday May 31, 2018 @02:02AM (#17194273)
That's true for limits approaching any number, so if that's important you'll need more than negative zero.
Re:Signed Integers Are Two’s Complement by lopmotr on Wednesday May 30, 2018 @11:38PM (#17193776)
Was that ever really a reason for signed magnitude, or did people just make use of the 2nd representation of zero because because it was available and they couldn't be bothered putting that information in another variable or using floating point or fixed point, or anything else that would have achieved the same result?
Re:Signed Integers Are Two’s Complement by userbinator on Wednesday May 30, 2018 @11:54PM (#17193823)
I have a feeling signed-magnitude predates binary and complement arithmetic --- it is, after all, the "natural" way humans work with numbers. A lot of the early non-binary computers used some form of sign-magnitude, all the way back to punch card formats:

https://en.wikipedia.org/wiki/Signed_overpunch

On the other hand (no pun intended), early mechanical (decimal) manual adding machines made use of complement arithmetic too:

https://en.wikipedia.org/wiki/Comptometer

https://en.wikipedia.org/wiki/Method_of_complements

Re:Signed Integers Are Two’s Complement by Animats on Thursday May 31, 2018 @01:55AM (#17194256)
Burroughs 5xxx and 6xxx machines used signed-magnitude.

Burroughs had a unique numeric representation. Numbers were 48 bits. Sign, sign of exponent, exponent, mantissa, with the binary point at the low end. Integers were thus valid floating point numbers. The math operations would maintain a value as an integer, with a zero exponent, if possible.

IEEE floating point also maintains integer values as integers until they don't fit, but the representation is not integer-like.

Re:Signed Integers Are Two’s Complement by Phrodo_00 on Thursday May 31, 2018 @01:22AM (#17194150)
TIL about signed overpunch

Except the "natural" way also recognizes a single zero with no sign, so it's still not accurately modeling that.

If you wanted to model natural arithmetic accurately you'd need 2 bits for the sign (positive, negative, unsigned). At that point, all of single bit signed magnitude, and complements are compromises.