> > convert a,b to their % of 0xFFFFFFFFF, add the two together, if the
> > result is greater than 100% then error.

For the percentage method to work, one must use a double, not float
because a float only has a mantissa of 25 bits which will drop off the
lower few bits which sometimes are what puts the answer "over the
top."  (It's 25 bits because the most significant bit is implied in
many floating point representations.)  It might be easier to just
convert both UInt32's to doubles, add and then check the result for
being
greater than 0xffffffff but doubles would still be needed

>     if (((a >> 1) + (b >> 1)) & 0x8000000) {
>     }
> 
>   which will basically remove the least sig. bit (shift right by 1)
>   and hence you add together, it wont overflow.. however, an overflow
>   can be determined by checking if the most significant bit is set.

This won't work because (for example):  a = 0x7fffffff; b =
0x80000001;  The shifting will drop the rightmost one in 0x80000001
which will cause a false no-overflow answer.  

Bill Smith
[EMAIL PROTECTED]

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to