But the whole question of dividing by ten, specifically, was to avoid multiplication as well as division:It doesn’t.
It avoids division.
Now, I had interpreted that as being dividing by 10, hence multiplying by the reciprocal of 10 using shift and add operations.single multiplication may be 10 clocks or so, a huge improvement over old XT machines that needed several times more (60-140 cycles). and division was costlier than multiplication. so if you had to divide by some fixed number and fast, it was better to program multiplication by reciprocal. and for multiplication by some other common values like 10, one could combine couple of shift and add operations and still be faster than actual multiplication.
But if @panic mode really meant multiplying by 10, that is very straightforward.
z = (z<<1) + (z<<3);
or
z <<= 1;
z += (z << 2);
So I think dividing by ten (which would be something that a cheap MCU might have to do a lot of in order to, for instance, convert values to BCD for display purposes) is a much more interesting example.
Even if we allow multiplication, the question of whether it is good enough comes into play (as it always must).
z = (x * 3277) >> 15;
only produces correct values until x = 16388. So it works as long as your numerator is no more than 14 bits (as always, the assumption is that we are talking about unsigned integers), which may well be good enough for some applications.



