views:

50

answers:

2

In Microsoft Visual C++, there is a constant called MAXDWORD defined in winnt.h as follows:

#define MAXDWORD 0xffffffff

It's useful as a high initial value for a 'double' when one is searching for the lowest value in a collection. Google though I might, I can't find the equivalent in standard headers on Linux, but I'm willing to bet there must be one.

I'm using:

  • uBuntu 10.04 64bit
  • g++ 4.4.3
+7  A: 

Standard solution is to use std::numeric_limits. For instance, std::numeric_limits<long>::max(). You could use any standard type instead of long there. You even can to specialize numeric_limits for custom types.

Kirill V. Lyadvinsky
correction: `unsigned long`
Gunslinger47
It's just an example. You could put there whatever you want.
Kirill V. Lyadvinsky
perfect, that's just what I need!
Boinst
+3  A: 
#  define UINT_MAX  4294967295U

Found in /usr/include/limits.h

Matt Joiner
thanks, that's useful too!
Boinst