I doubt this is causing an overflow . . . I'm not a compiler/assembly
expert, but if I remember the little bit of x86 assembly correctly, I
believe if you multiply two 16-bit ints, the result is put into a 32-bit
int.  It makes sense that the Dragonball does the same.  I'd suggest
breaking your code into a couple lines and look in the debugger:

ULong answer;
ULong temp;
int valueA;
Word valueB;

temp = (valueA * valueB);
answer -= temp;

This may yield helpful information.

Cheers,

-DGA

> Consider this code:
> 
> ULong answer;
> int valueA;
> Word valueB;
> 
> answer -= (valueA * valueB);
> 
> (note the "minus equals")
> 
> How does the compiler know what type to make the answer of the
> multiplication?  If valueA = 660 and valueB = 100, the answer 
> is larger than
> an int.  Will the complier automatically use a long int to 
> store the answer
> before doing the subtraction? I have a feeling that this is causing an
> overflow problem in my code.

-- 
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