xampla - 1 year ago 108

C++ Question

So I think I'm a bit confused. I'm searching information about the limits of the differents types of integers. I've seen that the limit for unsigned long int is 4294967295 but when I do:

`cout << numeric_limits<unsigned long int>::max() << endl;`

I'm getting:

`18446744073709551615`

And if I'm not wrong this number is the limit of unsigned long long, isn'it? So what is happening?

Thank you

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

Answer Source

I've seen that the limit for unsigned long int is 4294967295

Whoever told you that was *wrong*.

The limit for `unsigned long int`

will usually be that on systems for which the type is 32-bit.

But yours is evidently 64-bit, so you have a different limit.

this number is the limit of unsigned long long, isn'it?

Again, you're making assumptions about type width.

The width of types varies across compilers/platforms.

If you want to use types with a fixed size, then those do exist.

Recommended from our users: **Dynamic Network Monitoring from WhatsUp Gold from IPSwitch**. ** Free Download**