[rust-dev] Integer overflow, round -2147483648

Tony Arcieri bascule at gmail.com
Wed Jun 18 11:15:31 PDT 2014


On Wed, Jun 18, 2014 at 10:08 AM, Gábor Lehel <glaebhoerl at gmail.com> wrote:
>
> # Between a rock and a hard place
>
> Having dispatched the "easy" cases above, for category #3 we're left
> between the rock (wraparound on overflow is wrong) and the hard place
> (checking for overflow is slow).
>
> Even here, we may have options.
>

I really like what Swift did: define two sets of operators, a default one
which checks/errors on overflow, and a second set of "overflow operators"
(which look like &+ &- etc) when you need the performance of unchecked
operations or otherwise desire overflow behavior:

https://developer.apple.com/library/prerelease/ios/documentation/swift/conceptual/swift_programming_language/AdvancedOperators.html#//apple_ref/doc/uid/TP40014097-CH27-XID_37

-- 
Tony Arcieri
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20140618/e46ad77b/attachment.html>


More information about the Rust-dev mailing list