我是靠谱客的博主 舒适小虾米,最近开发中收集的这篇文章主要介绍java bigdecimal 小数位数,使用BigDecimal的小数点后的最大位数,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

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的小数点后的最大位数所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(57)

评论列表共有 0 条评论

立即
投稿
返回
顶部