本文介绍了使用BigDecimal的小数点后的最大位数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Java中 BigDecimal
值小数点后的最大位数是多少?
What is the maximum number of digits we can have after the decimal point of a BigDecimal
value in Java?
推荐答案
这几乎是无限的。如果将scale设置为整数的最大值,则可以在小数点后存储大约20亿个数字,但如果尝试执行此操作,可能会耗尽内存。如果您需要存储这么多的数字以确定限制是一个问题,那么您可能需要重新考虑程序的设计。
It's (almost) unlimited. You can store roughly 2 billion digits after the decimal point if scale is set to the maximum value of an integer, although you may run out of memory if you try to do this. If you need to store so many digits that the limit is a problem then you probably need to rethink the design of your program.
参见:
这篇关于使用BigDecimal的小数点后的最大位数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!