小数点后最多可以有多少位BigDecimal
Java 中的值?
它(几乎)是无限的。如果将比例设置为整数的最大值,则可以存储大约 20 亿位小数点后的数字,但如果尝试这样做,可能会耗尽内存。如果您需要存储如此多的数字以至于限制成为问题,那么您可能需要重新考虑程序的设计。
See the BigDecimal 文档 http://download.oracle.com/javase/6/docs/api/java/math/BigDecimal.html:
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).
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)