
25 Apr
2005
25 Apr
'05
11:04 a.m.
How about
a = b / 5; ?
Will that result in
a = (b >> 2) - b;
, i.e. still no division but only shift operations?
I sincerely hope NOT!
A = (B >> 2) - B = B/4 - B = -3/4 B
IMHO, divisions by non-powers of two cannot be achieved by simple shifts and adds/subtracts in one formula - you'd always need conditional jumps and loop constructs.
Reinhard