3 ms·
I wish there was an abs() function that returned the unsigned version of the signed input type and wasn't UB if you passed in the most negative value of the sig
by nyanpasu64 5y ago
I wish there was an abs() function that returned the unsigned version of the signed input type and wasn't UB if you passed in the most negative value of the signed type. Sadly neither C or C++ nor Rust's standard libraries have a built-in implementation of this, and sending the most negative integer into Rust's .abs() will panic in debug mode (is not intended to be used in properly implemented code).