avoid overflow in clipping code