That's good Ingvar, got me thinking.
But, since we're going for accuracy too.
1 Nautical Mile = 6076.11549 Feet
1 Mile = 5280 Feet
So the conversion is 1.150779449 (6076.11549/5280), and the number we need is [0.150779449 * 65536] or 9881.482. It's closer to 9881 than 9882
But the biggest problem is with the integer nature of the calculation. Most of the added accuracy is lost in the Low Word of the ** multiplication..
For instance, at 45.0 knots, the MPH is 51.78 MPH (45 * 1.150779449) which is closest to 51.8 MPH.
However, either of our previous formula's will only show 51.7 MPH.
Here's another way that does the same thing as the **, but also allows you to round the result according to the low Word of the multiplication.
Code:
Dummy = Dec_speed * 9881
Dummy = R0 ; Get High Word of Multiply result
IF R2 > 32768 then Dummy = Dummy + 1 ; Round to nearest .1 MPH
Dec_speed = Dec_speed + Dummy
This will hold the result to +/- 1/2 Least Significant Digit.
Best regards,
Darrel
Bookmarks