this post was submitted on 21 Oct 2023
258 points (94.8% liked)
Programmer Humor
19551 readers
1012 users here now
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
Rules
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
TIL!
I wonder how many languages out there do define what happens on integer overflow.
Languages with dynamic typing and implicit large-integer types, such as Python and Ruby, generally just convert to that large-integer type.
I figured Java would probably define the behavior in the JVM, but based on a quick web search it sounds like it probably doesn't by default, but does provide library methods to add or subtract safely.
Rust guarantees a panic by default, but provides library methods for wrapping, saturating, and unchecked (i.e. unsafely opting back in to undefined behavior).