C++ maximum non negative int -


What are the expected tasks on the following platforms, int, size etc.? Or is there a more acceptable way of doing this? (I made the following.)

  #define MAX_NON_NEGATIVE_INT ((int () ((unsigned)) -1) / 2))  

I < / P>

Edit: I should have said that I can not use any standard class, because I'm running without C runtime.

If you do not want to define (and you want a standard way of calculating boundaries) , Then do this:

  #include & lt; Limits & gt; Std :: numeric_limits & lt; Int & gt; :: min ()  

These ANSI values ​​are defined in boundaries:

  #define INT_MIN (-2147483647 * 1) / * Min (signed) ant Value * / #define INT_MAX 2147483647 / * Maximum (signed) int value * / # Define UINT_MAX 0xffffffff / * Maximum unsigned full value * /  

These are defined by BaseTsd.h:

  #define MAXUINT ((UINT) ~ ((UINT) 0)) # defined MAXINT ((INT) (MAXUINT> gt; 1)) # defined MININT ((INT) ~ MAXINT )  

Comments