Re: division by 7 without using division operator
- From: CBFalconer <cbfalconer@xxxxxxxxx>
- Date: Mon, 05 Feb 2007 21:10:48 -0500
"*** T. Winter" wrote:
"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.
And probably down to -2147483648.
--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
"A man who is right every time is not likely to do very much."
-- Francis Crick, co-discover of DNA
"There is nothing more amazing than stupidity in action."
-- Thomas Matthews
.
- Follow-Ups:
- Re: division by 7 without using division operator
- From: Richard Heathfield
- Re: division by 7 without using division operator
- References:
- division by 7 without using division operator
- From: krypto . wizard
- Re: division by 7 without using division operator
- From: Francois Grieu
- Re: division by 7 without using division operator
- From: *** T. Winter
- division by 7 without using division operator
- Prev by Date: Re: [OT] cat was Re: Malloc
- Next by Date: Re: [OT] cat was Re: Malloc
- Previous by thread: Re: division by 7 without using division operator
- Next by thread: Re: division by 7 without using division operator
- Index(es):