概述
What is the maximum number of digits we can have after the decimal point of a BigDecimal value in Java?
解决方案
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.
Immutable, arbitrary-precision signed decimal numbers. A BigDecimal consists of an arbitrary precision integer unscaled value and a 32-bit integer scale. If zero or positive, the scale is the number of digits to the right of the decimal point. If negative, the unscaled value of the number is multiplied by ten to the power of the negation of the scale. The value of the number represented by the BigDecimal is therefore (unscaledValue × 10-scale).
最后
以上就是舒适小虾米为你收集整理的java bigdecimal 小数位数,使用BigDecimal的小数点后的最大位数的全部内容,希望文章能够帮你解决java bigdecimal 小数位数,使用BigDecimal的小数点后的最大位数所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复