logoalt Hacker News

xigoitoday at 3:22 PM2 repliesview on HN

If you need wraparound, you should not use signed integers anyway, as that leads to undefined behavior.


Replies

ratmicetoday at 3:31 PM

Presumably since this language isn't C they can define it however they want to, for instance in rust std::i32::MIN.wrapping_sub(1) is a perfectly valid number.

show 1 reply
umanwizardtoday at 3:34 PM

Signed overflow being UB (while unsigned is defined to wrap) is a quirk of C and C++ specifically, not some fundamental property of computing.

show 2 replies