I'm converting some code over to Picaxe, and need to express the ratio of two unsigned 16 bit integers as a percentage in the form pp.p%.
The original 32 bit code was simple:
A = 1000 * x / y ' Given x<=Y. Returns 0 - 1000 for all values. ie 3/4 = 750; 45000/60000 = 750.
I just can't seem to find an 'elegant' way to do this on a 20M2. All efforts so far have required loops, shifts, iterations or other unnatural actions.
I know I can get the MSW and LSW of 1000*x - but then what?
Suggestions?
The original 32 bit code was simple:
A = 1000 * x / y ' Given x<=Y. Returns 0 - 1000 for all values. ie 3/4 = 750; 45000/60000 = 750.
I just can't seem to find an 'elegant' way to do this on a 20M2. All efforts so far have required loops, shifts, iterations or other unnatural actions.
I know I can get the MSW and LSW of 1000*x - but then what?
Suggestions?