Re: Working with negative numbers



Bill Pursell wrote:

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...

I already understand the number system.
I don't understand the following terms:
"top half of the integers"
"moving them to the bottom"

--
pete
.



Relevant Pages

  • 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. ... bottom, with the zeros overlapping. ...
    (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)
  • Re: FYI - Nikon 200-400mm VR available at B&H
    ... it would be a nice complement to my 18-200. ... where the 18-200 stops. ... Don (e-mail link at home page bottom). ...
    (rec.photo.digital.slr-systems)
  • 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)