问题
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.
回答1:
It depends on the system. On Intel Linux they are the same. check limits.h
回答2:
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).
回答3:
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.
来源:https://stackoverflow.com/questions/9257065/int-max-in-32-bit-vs-64-bit-environment