Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the Linux equivalent to MAXDWORD?

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
like image 943
Boinst Avatar asked Jul 14 '10 04:07

Boinst


2 Answers

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.

like image 63
Kirill V. Lyadvinsky Avatar answered Sep 20 '22 11:09

Kirill V. Lyadvinsky


#  define UINT_MAX  4294967295U

Found in /usr/include/limits.h

like image 33
Matt Joiner Avatar answered Sep 23 '22 11:09

Matt Joiner