处理算术溢出UInt32(CUnsignedInt)

处理算术溢出UInt32(CUnsignedInt)

问题描述:

有没有使用Swifts UInt32(CUnsignedInt)处理算术溢出的方法?处理算术溢出UInt32(CUnsignedInt)

你可以在这里使用这些方法,我相信这也是不同规模

UInt32.addWithOverflow(x,y) UInt32.multiplyWithOverflow(x, y) UInt32.divideWithOverflow(x, y) UInt32.subtractWithOverflow(x, y)

他们每个人的返回大小为2元组,结果,以及是否溢出或全部Int同样的方法不。

引用自How does one trap arithmetic overflow errors in Swift?