Re: Even-Odd sorting
In article <MPG.22a1d098f0 1bef2989cdd@new s.sunsite.dk>,
jcoffin@taeus.c om says...
[ one's complement, two's complement, sign/magnitude and 'i&1' ]
Thinking about it a moment longer, that's not true. It works on
sign/magnitude and two's complement, but breaks on one's complement.
So, the original suggestion breaks on two's complement, and my version
breaks on one's complement. At least for me, one's complement machines
fall into that category that I feel fairly safe ignoring -- and I'm one
of probably fewer than a half dozen regular participants here who's
actually worked on a machine that used one's complement for integers.
In theory, I can also see the remote possibility of a biased
representation, in which the bias was odd, where it would also break. I
can't quite imagine anybody doing that though: given the requirement
that non-negative signed numbers and unsigned numbers have the same
representation, you'd need to use the same bias on unsigned numbers as
well, and making math on those work correctly seems a bit cumbersome
(about the only obvious way I can think of would be to remove the bias,
do the math, then reapply the bias). Of course, such a representation
isn't allowed under either C99 or C++ 0x (except under the as-if rule,
if the implementation made it always act like an allowed representation,
of course).
--
Later,
Jerry.
The universe is a figment of its own imagination.
In article <MPG.22a1d098f0 1bef2989cdd@new s.sunsite.dk>,
jcoffin@taeus.c om says...
[ one's complement, two's complement, sign/magnitude and 'i&1' ]
It's always true in those three representations .
sign/magnitude and two's complement, but breaks on one's complement.
So, the original suggestion breaks on two's complement, and my version
breaks on one's complement. At least for me, one's complement machines
fall into that category that I feel fairly safe ignoring -- and I'm one
of probably fewer than a half dozen regular participants here who's
actually worked on a machine that used one's complement for integers.
In theory, I can also see the remote possibility of a biased
representation, in which the bias was odd, where it would also break. I
can't quite imagine anybody doing that though: given the requirement
that non-negative signed numbers and unsigned numbers have the same
representation, you'd need to use the same bias on unsigned numbers as
well, and making math on those work correctly seems a bit cumbersome
(about the only obvious way I can think of would be to remove the bias,
do the math, then reapply the bias). Of course, such a representation
isn't allowed under either C99 or C++ 0x (except under the as-if rule,
if the implementation made it always act like an allowed representation,
of course).
--
Later,
Jerry.
The universe is a figment of its own imagination.
Comment