4 ms·
While this is true on the machine level, it also really depends on your programming language. Certain languages like Python or Ruby automatically convert a sma
by Tainnor 6y ago
While this is true on the machine level, it also really depends on your programming language.
Certain languages like Python or Ruby automatically convert a smaller integer type to a larger, unbounded one. Other languages like Swift (or Rust in debug mode, I believe) prefer to throw an error upon integer overflow instead of silently wrapping. I believe that the silent wrapping behaviour in e.g. C and Java is a decision that prioritises performance over safety, as this is behaviour that you rarely want, and if you do, there should be better ways of expressing it.