Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


Out of curiosity... did you ever fall into the trap of using

    numeric_limits<T>::min()
instead of

    numeric_limits<T>::lowest()
? Because I did.


The distinction is only relevant for floating point types, is it not?


Yes, I believe so.


Yeah, 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().




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: