整数距离计算在减少之前溢出
作者: Afloat16创建于 2026年9月29日更新于 2026年9月29日
def _difference(x, y): # Subtract integers exactly before converting the distance to floating point. if x.dtype.kind in "uib" and y.dtype.kind in "uib": return np.asarray(x.astype(object) - y.astype(object), dtype=np.float64) dtype = np.result_type(x.dtype, y.dtype, np.float64) return x.astype(dtype, copy=False) - y.astype(dtype, copy=False)
内容来源: ddbourgin/numpy-ml