c++cunsigned-integer

What's a portable value for UINT_MIN?


In limits.h, there are #defines for INT_MAX and INT_MIN (and SHRT_* and LONG_* and so on), but only UINT_MAX.

Should I define UINT_MIN myself? Is 0 (positive zero) a portable value?


Solution

  • If you want to be "typesafe" you could use 0U, so if you use it in an expression you will have the correct promotions to unsigned.