4 ms·
I used intmax_t just yesterday in an ODBC type conversion test. I wrote a template for use in a Google Test typed test to find the highest and lowest values su
by SloopJon 6y ago
I used intmax_t just yesterday in an ODBC type conversion test. I wrote a template for use in a Google Test typed test to find the highest and lowest values supported by the client and server type. Something like:
max(
static_cast<intmax_t>(
numeric_limits<T>::lowest()),
static_cast<intmax_t>(
numeric_limits<U>::lowest()))
I tried std::common_type first, but it didn't quite do the trick.
- secondcoming 6y agoOut of curiosity... did you ever fall into the trap of using numeric_limits<T>::min() instead of numeric_limits<T>::lowest() ? Because I did.
- saagarjha 6y agoThe distinction is only relevant for floating point types, is it not?
- secondcoming 6y agoYes, I believe so.
- SloopJon 6y agoYeah, min() returns the most negative int, so it seems like it should do the same for float. Then the float with the least magnitude could have been, say, smallest().