Hi Dieter,
dvholten apache.org wrote on 11/27/2006 05:13:38 AM:
> + // the previous implementation used a simple
+0.5d to do some
rounding.
> + // but that is just rounding towards
+inifitity.
Actually the two should give the same result:
(((int) ((a1 + i * da * stepSize) + .5) <<
24)) |
The quantity (a1 + i * da * stepSize) must always be
positive, so adding +.5 and integerizing will always give
correct rounding. That said your extracting part of the
computation is probably a win (depends if compiler is
smart enough, in my experience Java compilers aren't).
> + // this implementation uses an implied
multiplication by 2 ( in
tempX )
> + // and then a signed right-shift to do signed
rounding.
> + // this also spares a float-add per
color-band.
> + // we could also save the shift when we use a
different
and-mask
> + // and a different left-shift, but that would
obfuscate too
much...
Actually, if this is really a hot spot it would be best
to turn this
into a fixed point calculation. BTW, I don't think saving
the shift
would really obfuscate the code too much.
> }
> + Math.round( 2.6 );
> }
I think this was left over from testing?
------------------------------------------------------------
---------
To unsubscribe, e-mail: batik-dev-unsubscribe xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-help xmlgraphics.apache.org
|