32 位环境中的 int_max 与 64 位环境中的 int_max
32 位和 64 位环境中的 INT_MAX
是否不同?看起来确实是这样,虽然我听人说64位环境只是使用32位环境的INT_MAX。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这取决于系统。在 Intel Linux 上它们是相同的。检查
limits.h
It depends on the system. On Intel Linux they are the same. check
limits.h
你的问题可能太笼统了,但在典型的 64 位环境(x86-64)上, int 实际上与 386 上的大小相同(请记住,这也取决于操作系统,而不仅仅是体系结构)。 C 标准仅限制下限(如 wiki)。
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).
对于某些编译器,
long
类型存在差异。也就是说,当编译为 32 位时,long
为 32 位,否则编译为 64 位,而int
在这两种情况下均为 32 位。但根据你想要的,你的问题的答案可能是使用
int64_t
(或你的编译器的等效项,可能是__int64
或类似的东西),如果你想确保你有一个 64 位 int。所以你应该澄清你的问题。
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, whileint
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.