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

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

问题描述

背景:我想存储精确到小数点后四位的数字,而不能四舍五入.所以我想到了在内部使用整数.例如,内部将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天全站免登陆