Chris Antos wrote:
> 
> v2 of my app HandyShopper uses Long to represent cents.
> 
> however, i discovered very quickly that fixed-point math is limited.  think
> about longhand multiplication (since this is what you're emulating).
> 
> let's take 400.00 and 1200.00 for instance.  we convert them to 40000 and
> 120000 as Longs, and now we multiply them.  whups, overflow.  the result is
> 4,800,000,000 which is larger than 32 bits (much less 31 to allow negative
> numbers).  so the problem is that although you can divide by 100 afterwards
> (to get us back to only 2 "decimal" places) and the final result would
> actually fit, it has already overflowed before you have an opportunity to
> shift the decimal place correctly.
> 


have you tried using long long types?

:P

Reply via email to