在 JVM 中,64 位整数是否比 32 位整数效率低? [英] Are 64 bit integers less efficient than 32 bit integers in the JVM?

查看:29
本文介绍了在 JVM 中,64 位整数是否比 32 位整数效率低?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景:我想存储精确到小数点后 4 位的数字,无需四舍五入.所以我想在内部使用整数;例如,12.3456 在内部表示为 123456.但是对于 32b 个整数,我最多只能计算最多 214748,这是非常小的.

Background: I want to store numbers that are precise to 4 decimal places, without roundoff. So I thought of using integers internally; for example, 12.3456 is represented as 123456 internally. But with 32b integers, I can count only upto 214748, which is very small.

我想 64 位整数是解决方案.但是,给定一台运行 64 位 JVM 的机器,涉及 64 位整数的操作是否效率低于 32 位整数?

I guess that 64-bit integers are the solution. But are operations involving 64-bit integers less efficient than 32-bit integers, given a machine running a 64-bit JVM?

顺便说一句,我正在使用信息检索包 (Solr)、优化包 (Drools) 和其他用 Java 编写的包,它们可能无法很好地处理十进制数据类型(如果你建议的话)).

BTW, I am using an information retrieval package (Solr), an optimization package (Drools) and other packages written in Java, and they may not play well with decimal datatype (if you suggest it).

推荐答案

即使速度较慢,我也怀疑这是否会成为您系统的瓶颈.您很可能会在程序的其他部分遇到更严重的性能问题.

Even if it is slower, I doubt this would be the bottleneck in your system. You are very likely going to have more significant performance issues in other parts of your program.

此外,这个问题的答案提供了更多详细信息,但基本上它依赖于平台.".64 位不一定会比 32 位慢.

Also, the answer to this question provides more details, but basically "It's platform dependent.". It's not necessarily true 64 bit will be slower than 32 bit.

这篇关于在 JVM 中,64 位整数是否比 32 位整数效率低?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆