commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mika Riekkinen <>
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

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message