Why can't you just check if errno is equal to ERANGE?
问题 I've been trying to properly convert a char array to a long with strtol , check if there was an overflow or underflow and then do an int cast on the long. Along the way, I've noticed a lot of code that looks like this if ((result == LONG_MAX || result == LONG_MIN) && errno == ERANGE) { // Handle the error } Why can you not just say if(errno == ERANGE) { // Handle the error } From my understanding, if an underflow or overflow occur, errno is set to ERANGE in both cases. So is the former really