Re: Working with negative numbers




Frederick Gotham wrote:
(1) Sign-magnitude: The bit-pattern is exactly the same.
(2) One's complement: Toggle each bit.
(3) Two's complement: Toggle each bit, then add 1.


This has always sort of bugged me. The description of
2's complement above is a nice way to describe the
technique for comprehending the bit pattern used to
represent an integer, but it's not a good way to describe
the system. I think a better description is: take the top
half of the unsigned integers and move them to the bottom.
Unfortunately, I can't find the right wording to explain
that description completely. Any thoughts on expanding
it sufficiently to describe it, without making it too verbose?

signed magnitude is taking the top half
of the integers, flipping them over and moving them to the
bottom, with the zeros overlapping. (From this description,
it's far more obvious why 2's complement is simpler.)

One's complement is derived by moving the top half
to the bottom and shifting up by one to make the zeros
overlap.

It feels like those descriptions are not clear to the clueless
newbie, however. I'm not sure they're even clear to anyone
unless they already understand the number system...

.



Relevant Pages

  • Re: Working with negative numbers
    ... Two's complement: Toggle each bit, ... which we can easily see has no overflow problems. ... just a truncating division. ...
    (comp.lang.c)
  • Re: Working with negative numbers
    ... Two's complement: Toggle each bit, ... half of the unsigned integers and move them to the bottom. ... One's complement is derived by moving the top half ...
    (comp.lang.c)
  • Re: Working with negative numbers
    ... Two's complement: Toggle each bit, ... half of the unsigned integers and move them to the bottom. ... One's complement is derived by moving the top half ...
    (comp.lang.c)
  • Re: Working with negative numbers
    ... Bill Pursell wrote: ... Two's complement: Toggle each bit, ... This has always sort of bugged me. ...
    (comp.lang.c)
  • Complemented Lattices
    ... Let L be a complemented lattice. ... a top or max element 1 and a bottom or min element 0 and ... If L is a distributive lattice, ... has a unique complement, then L is distributive? ...
    (sci.math.research)