resample: avoid overflow in phase calculation