On Sun, 03 Jul 2005 18:45:50 +0200, Hannes Allmaier wrote:
Thanks for your reply!
The only difference is the null statement (the semicolon) in the first
example.
Sorry, but what does that mean?
You quoted two lines of code. One ended ";;" the other ";" but they were
otherwise identical. It looks odd that you quoted two (almost) identical
lines of code.
For larger numbers it does matter, so on that count alone your simplification wouldn't work in all cases.
Yes you're right, but I'm dealing here with small numbers.
How small are these numbers? Even with N < BitsLeft
(CurrentBfr << (32 - BitsLeft)) >> (32 - N)
is only equivalent to
CurrentBfr >> (Bitsleft - N)
for a very small set of values for CurrentBfr. Take N = 0 and BitsLeft
= 1 and the two expressions become:
(CurrentBfr << 31) >> 32 and CurrentBfr >> 1
If CurrentBfr is 16 bits (you did not give the size) then these are
equivalent for zero values. If 32-bit ints are used, then they are the
same for exactly two values. With 64-bit ints they are equivalent only
for 0..0x1ffffffff which is 0.000000047% of the possible values CurrentBfr
can take.
But either your ints are about 32 bits in size or your test values are
big enough to cause problems, because you say that your version does not
work. Does this helps you to see why?
--
Ben.