News for hackers. Stuff that matters.
Re:A Special Kind of Hell: intmax_t in C and C++ by SloopJon on Saturday December 05, 2020 @04:25PM (#25318529)
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.
Re:A Special Kind of Hell: intmax_t in C and C++ by secondcoming on Saturday December 05, 2020 @04:29PM (#25318570)
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.
Re:A Special Kind of Hell: intmax_t in C and C++ by saagarjha on Saturday December 05, 2020 @04:35PM (#25318621)
The distinction is only relevant for floating point types, is it not?
Re:A Special Kind of Hell: intmax_t in C and C++ by secondcoming on Sunday December 06, 2020 @08:58AM (#25323478)
Yes, I believe so.
Re:A Special Kind of Hell: intmax_t in C and C++ by SloopJon on Sunday December 06, 2020 @01:36AM (#25321635)
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().