commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mika Riekkinen <mriekki...@yahoo.com>
Subject Re: [lang] Math class
Date Thu, 22 Aug 2002 10:46:41 GMT
> keep the >> 1 or can
> we use a /2? I'm under the impression that there is
> no longer any
> difference in modern Java compiling.

In my opinion, when we divide integer by 2, for
the sake of clarity, we should use >> operator.
3/2 == 1, with integer division.
3>>1 == 1, makes it more clear, what is going on.

> The name feels a little weird as I can see a
> developer expecting to have a
> sum(int[]) as well.

You are right. That's the only name I can think
for the method in question.

> I'll have to puzzle through sum2 as an exercise and
> figure out why it's
> the same as sum :) My byte-manipulation experience

Hint: multiplication and division are done in
differend order. Which by the way causes these
different characteristics I talked about.
If we would change the return value to long,
sum2 would be unncessary. (no overflows anymore)


__________________________________________________
Do You Yahoo!?
HotJobs - Search Thousands of New Jobs
http://www.hotjobs.com

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message