Bitwise operations:
multiply by 2 == <<1
divide by 2 == >>1
add == +
subtract = -
So, if what I understand you to mean by "saturated" arithmetic, with limits of +-21474, then the problem becomes much more comprehensible. In any case, please clarify if I am making the appropriate assumptions. Your terminology is not what I have used in the past.
rubberman
Posting Virtuoso
1,564 posts since Mar 2010
Reputation Points: 277
Solved Threads: 179
You'll also need to utilize modulus operations to determine if there are "left over bits".
rubberman
Posting Virtuoso
1,564 posts since Mar 2010
Reputation Points: 277
Solved Threads: 179
You have control statement with comparison and casts in your code! Also modulus was not allowed!
pyTony
pyMod
5,359 posts since Apr 2010
Reputation Points: 782
Solved Threads: 852
Missed that (no modulus operations)... Thanks! Naturally, modulus operations are basically "divide-by and test for remainder", and since divides are disallowed, that makes sense.
rubberman
Posting Virtuoso
1,564 posts since Mar 2010
Reputation Points: 277
Solved Threads: 179