[cp-patches] FYI: Point.setLocation() fix

Tom Tromey tromey at redhat.com
Tue Jun 27 17:41:08 UTC 2006

>>>>> "David" == David Gilbert <david.gilbert at object-refinery.com> writes:

>> I thought Math.round(), but the API docs said it was equivalent to
>> Math.floor(x + 0.5) and it returns a long, so I thought I might as
>> well call Math.floor() directly.

Usually it is a little better to use the Math API directly.  An
implementation may optimize this, and it is also slightly clearer.

That said, I don't care very much, unless we think this method is
likely to be used in a performance-critical way.

David>     Math.round() fails only for the test
David>     cases where the values are outside the range Integer.MIN_VALUE to
David>     Integer.MAX_VALUE (can't say I understand why, perhaps it is the
David>     intermediate cast to 'long' inside Math.round() (*)).

Yeah.  There's always Math.round((float) arg).

Thanks for trying this out.  I think we can leave it as is.


More information about the Classpath-patches mailing list