clipper-java icon indicating copy to clipboard operation
clipper-java copied to clipboard

Overflow when using values too large for integers

Open dmac000 opened this issue 9 years ago • 0 comments

Using large integers in the input paths gives overflowed values in the results. This seems to be solved by removing some casts from the library.

In ClipperOffset.java, there are casts to int, where the expected type is long. These casts can be removed:

destPoly.add( new LongPoint( (int) Math.round( srcPoly.get( 0 ).getX() + X * delta ), (int) Math.round( srcPoly.get( 0 ).getY() + Y * delta ) ) );

also in Edge.java:

return (int) (edge.getBot().getX() + Math.round( edge.deltaX * (currentY - edge.getBot().getY()) ));

dmac000 avatar Oct 07 '16 13:10 dmac000