4 ms·
I've run into programmers that think something terrible is going to happen if you use an unsigned int for anything.
by Gibbon1 7y ago
I've run into programmers that think something terrible is going to happen if you use an unsigned int for anything.
- perl4ever 7y agoIs there a popular language these days that throws an exception whenever an unsigned int overflows?
- vertex-four 7y agoRust in debug mode or with a compiler option will panic if a number overflows.
- perl4ever 7y agoHuh. That doesn't sound like something people use in production code. Maybe a hardware feature is needed? I mean, it's normal with floating point to handle overflow in a more sensible way, isn't it...
- poilcn 7y agoThere are safe operation extensions like "save add", "save mul" for numbers in Rust which would detect overflows, but you'd have a drawback as it won't return just the number (of type u64, for example), it would return result<u64> and you'd be forced to handle it.
- vertex-four 7y agoThere's also functions which people do use to specify specific behaviour no matter the release mode, where handling overflows properly is particularly important - e.g. cryptography-related code.
- Gibbon1 7y agoI think you can specify 'checked' in C# which will result in an exception on overflow.