4 ms·
Even worse, checking for overflow before casting can be tricky: https://stackoverflow.com/questions/526070/handling-overflow-when-casting-doubles-to-integers-in
by nwellnhof 2mo ago
Even worse, checking for overflow before casting can be tricky: https://stackoverflow.com/questions/526070/handling-overflow-when-casting-doubles-to-integers-in-c https://stackoverflow.com/questions/526070/handling-overflow...
It's sad that comparison operators in C/C++ can lead to UB. Comparing unsigned to signed ints or comparing floats to ints is something the compiler could make work reliably at very little extra cost.