Scale a 16 bit number to 3 decimal digits
On Tue, 18 Sep 2001 18:08:40 -0600, you wrote:
>Good day to all.
>Has anyone run across a routine to scale a 16 bit number to 3 decimal
>digits (0-999). I'm sure that I saw this a couple of years ago but can't
>find it in my snippets file or on piclist.com.
Do a 16x16 Multiply by 1000 and use the top byte as the result. Use
1000 rather than 999 to get closer rounding.
If code is tight and accuracy not too important, if you can multiply
by 1024 instead this will use less code - just limit the number to
63936 and shift it down 6 places.
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads
In reply to: <email@example.com>
See also: www.piclist.com/techref/microchip/devices.htm?key=pic
You must be a member of the
piclist mailing list
(not only a www.piclist.com member) to post to the