Re: Beginner Projects
- From: Joshua Cranmer <Pidgeot18@xxxxxxxxxxx>
- Date: Thu, 30 Aug 2007 13:19:33 GMT
Roedy Green wrote:
On Thu, 30 Aug 2007 00:32:11 -0400, Lew <lew@xxxxxxxxxxxxx> wrote,
quoted or indirectly quoted someone who said :
. OTOH, this counts as "premature optimization" in many cases.
It is simpler code, so I don't count it as optimisation. Optimisation
that gets you in trouble is verbose, harder-to-maintain code. I
figure every student should be familiar with odd/even idiom.
Sometimes it can save you.
int mid = (low + high) / 2;
int mid = (low + high) >>> 1;
The first one breaks when low + high > 2^31-1, the second one doesn't (only when low + high > 2^32 - 1).
In other news, premature optimization only counts IMO when the change involves non-trivial optimizations.
--
Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald E. Knuth
.
- Follow-Ups:
- Re: Beginner Projects
- From: Patricia Shanahan
- Re: Beginner Projects
- From: Lew
- Re: Beginner Projects
- References:
- Beginner Projects
- From: Pseudo Silk Kimono
- Re: Beginner Projects
- From: Roedy Green
- Re: Beginner Projects
- From: Lew
- Re: Beginner Projects
- From: Roedy Green
- Beginner Projects
- Prev by Date: Re: How can i implements a class like an HashMap but with 2 keys ?
- Next by Date: Re: Beginner Projects
- Previous by thread: Re: Beginner Projects
- Next by thread: Re: Beginner Projects
- Index(es):