Date: Sat, 26 Jan 2008 17:21:56 -0500
From: Sean Conner <spc at conman.org>
I came across this bit of code from
http://www.hackersdelight.org/ to
divide by 10:
I think that goes back to my original suggestion of effectively
multiplying by a scaled reciprocal approximation of 0.1. The 6 in
the last computation statement appears to be some sort of rounding
factor.
The problem as stated however, was to calculate x/10 and mod(x,10)
(i.e. the remainder). Dwight seems to have figured this one out at
least for the range of 0..799.
If you/re a PIC programmer, there's a very cool web site that
features a code generator for various problems:
http://www.piclist.com/techref/piclist/codegen/index.htm
But double-check the code that's generated; I've occasionally found
some errors.
Cheers,
Chuck