logoalt Hacker News

Integer Overflow Checking Cost

35 pointsby iwsklast Thursday at 12:48 AM8 commentsview on HN

Comments

gnabgiblast Thursday at 12:53 AM

2014 (probably? Or 2008. Old and no date) Previously (166 points, 2014, 107 comments) https://news.ycombinator.com/item?id=8765714

show 2 replies
tcfhgjtoday at 8:52 AM

Definitely cheaper than using Electron I would say

mayofftoday at 8:04 AM

In Swift (Apple’s C++ successor), the normal operators (`+`, `-`, `*`) trap on overflow for integer types. If you want twos complement wrapping, you can use `&+`, `&-`, and `&*`.

Given that Apple has been making its own CPU cores for years now, I suspect overflowing checking on Apple CPUs is virtually free (aside from code size).

show 2 replies
ardlinetoday at 7:00 AM

[flagged]