DWord math in PBASIC
Way to go parallax, PBasic has no floating bit support (not even emulated) and you don't have a math function "DivMul(a, b, c)" which calculates ab/c where the result is 16bits, but the intermediates may not be...
So, Given that you can bit shift, multiply (and find the lower 16 bits and higher 16 bits), and divide (and find the remainder/quotient), and find the highest bit of a number, whats a good algorithm to calculate Result = ((ab)/d) AND Remainder = (a*b mod d)
a,b, and d are all 16 bit words, all values are non-negative (d is non-zero), and the final Result/Remainder fit in 16 bits.
You have a function Multiply(a, b, ref low, ref high) sets low/high with the low/high 16 bits of a * b (respectivly)