12-03-2004, 12:42 AM
Ashkael,Dec 2 2004, 05:48 PM Wrote:Hmm? How can multiplication not be commutative?
Edit: Talking about crappy routines
I'm guessing that it would be something to do with the low order bits.
As an example, on a machine with an 8 bit accumulator, of you want to perform 16*16*(1/16) (doing shift for division) you will get an overflow if you do the two multiplications first, since 256 doesn't fit in an 8 bit accumulator, but if you do 16*(1/16)*16 you get the correct answer. Unfortunately, if you do 15*16*(1/16) in the way that worked in the above example (15*(1/16)*16) you will get the 'wrong' answer due to loss of precision, but would have been fine if you multiplied the two numbers first before the division.