Re: Working with negative numbers
- From: "Bill Pursell" <bill.pursell@xxxxxxxxx>
- Date: 27 Jun 2006 22:34:24 -0700
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...
.
- Follow-Ups:
- Re: Working with negative numbers
- From: Eric Sosman
- Re: Working with negative numbers
- From: pete
- Re: Working with negative numbers
- From: Giorgio Pastore
- Re: Working with negative numbers
- References:
- Working with negative numbers
- From: Frederick Gotham
- Working with negative numbers
- Prev by Date: Re: Segfault City
- Next by Date: Re: Multiplications by powers of 2
- Previous by thread: Re: Working with negative numbers
- Next by thread: Re: Working with negative numbers
- Index(es):
Relevant Pages
|