Kübek Tonyemail (remove spam text)
I forgot to reply to your question Philip :)
anyway here goes:
Philip Martin wrote:
>get into this figure to convert it into MPH. Thus 122.75 / 12.63
>would be 9.718 mph.
>12275 = 2F (msb) & F3 (lsb) / 1263 = 04 (msb) & EF (lsb) = 00 09 (msb)
>83 (lsb) or 9.908.
>Would I be right in thinking that route b) is the more correct way to
>and the error is due to the maths capability of the math routine?
Well not really, you start with the value 12.275 which has as many digit
as you need
then you divide it, this way you are ( alomost ) bound to 'loose'
If you instead convert it to 8.16 format you will have this:
122 = 0x7A
275 * 65.534 = 18021.85 = 0x4666
Divide by 12.63 will generate:
to convert to 'fixed 4 digit after decimal point''
Multiply by 10000 / 256*256 = 0.152588 ( rounded )
0x017A2D which is 96813 in decimal with 4 digits after dp we get
9.6813 mph which is closer than your original formulas.
I'm sorry for the bad example to the maths pro's on the list but I'm in
a hurry :)
Tony Kübek, Flintab AB
http://www.piclist.com hint: The PICList is archived three different
ways. See http://www.piclist.com/#archives for details.
See also: www.piclist.com/techref/microchip/math/index.htm?key=math
You must be a member of the
piclist mailing list
(not only a www.piclist.com member) to post to the