Rio
Rio

Reputation: 14892

int_max in 32 bit vs 64 bit environment

Is INT_MAX different between a 32-bit and 64-bit environment? It seems like it would be the case, though I've heard people say that the 64-bit environment just uses the 32-bit environment's INT_MAX.

Upvotes: 2

Views: 8777

Answers (3)

Mr Lister
Mr Lister

Reputation: 46589

For some compilers, there is a difference with the long type. That is, long is 32 bits when compiling for 32 bits and 64 bits otherwise, while int is 32 bits in both cases.

But depending on what you want, the answer to your question may be to use int64_t (or the equivalent for your compiler, maybe __int64 or something like that) if you want to make sure you have a 64-bit int.

So you should clarify your question.

Upvotes: 0

Tomas Pruzina
Tomas Pruzina

Reputation: 8887

Your question is perhaps too generic, but on typical 64bit enviroment (x86-64) int is defacto the same size as on 386 (keeping in mind that this also depends on OS, not just architecture). C standard only limits lower bounds (as described on wiki).

Upvotes: 0

Anycorn
Anycorn

Reputation: 51505

It depends on the system. On Intel Linux they are the same. check limits.h

Upvotes: 6

Related Questions