32 位环境中的 int_max 与 64 位环境中的 int_max

发布于 2025-01-05 11:46:29 字数 86 浏览 2 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

云朵有点甜 2025-01-12 11:46:29

这取决于系统。在 Intel Linux 上它们是相同的。检查limits.h

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

走野 2025-01-12 11:46:29

你的问题可能太笼统了,但在典型的 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).

绿光 2025-01-12 11:46:29

对于某些编译器,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, 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文