CompuServe Messages

32 divide

    08-Jan-93 23:48:50
Sb: #31309-32 divide
Fm: Shraddhan 70374,754
To: John Draper 76703,4322
The following code does NOT work: move.l #1000000,d0 one million move.l #10,d1 divided by 10 divs d1,d0 is a million! rts .. because the result of the division is > 2^16 Richard, I looked up in some code I wrote a while ago. To divide a 32 bit number by another number giving a 32 bit result, I avoided the issue by passing the values to a routine which could handle ANY size numbers (subject to memory limitations). The fact that I took this route makes me think that the problem is rather difficult. Try looking up Knuth's book on Semi-numerical algorithms. He gives an algorithm for multiple-precision division. Do you really need to do this? Can you not avoid the problem? One other thought – you can do the division on a bit-by-bit basis, though this will be slow. Regards, Shraddhan – via Whap! from Hertfordshire in the UK