Re: division by 7 without using division operator



In article <1170710144.518843.62070@xxxxxxxxxxxxxxxxxxxxxxxxxxx> "Francois Grieu" <fgrieu@xxxxxxxxx> writes:
....
To suceed in these interviews, I fear that you must not be so smart as
to outsmart the person asking the questions. So I suspect the right
answer might have been

number *= 0.142857142857143; // divide by 7

which indeed, in quite a few contexts, is an approriate answer.

Indeed, it gives the correct answer for all integers from 0 to
2147483647.
--
*** t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~***/
.