The maximum value of "unsigned long int" in C ++

How do I know what is the maximum assignable value for a variable of type unsigned long int?

+4
source share
3 answers

The obvious way would be to use std::numeric_limits<unsigned long>::max();

+18
source

Another way to find out:

 unsigned long int i = (unsigned long int) -1; printf("%lu\n", i); 
+7
source

In a simple way:

 unsigned long int i = -1; std::cout << i; 
+2
source

Source: https://habr.com/ru/post/1497683/


All Articles