[swift-users] Int32.divideWithOverflow

Dave Abrahams dabrahams at apple.com
Wed Nov 9 23:34:39 CST 2016

on Wed Nov 09 2016, Peter W A Wood <swift-users-AT-swift.org> wrote:

> I am using Swift to generate some tests with overflowing 32-bit
> integers. I have used the Int32.<op>WithOverflow functions but have
> come across a problem dividing Int32.min by -1 with overflow. I get an
> overflow error:
>     error: division '-2147483648 / -1' results in an overflow
>     Int32.divideWithOverflow(Int32.min, -1)
> Is this the expected behaviour?


   -Int64(Int32.min) > Int64(Int32.max)

which is to say that the result of the division can't be expressed as
an Int32.


More information about the swift-users mailing list