简体   繁体   English

如何处理大于Double.MAX_VALUE的数字

[英]How to handle numbers greater than Double.MAX_VALUE

I am continuously adding a stream of numbers and calculating their average in JAVA. 我不断添加数字流,并用JAVA计算它们的平均值。 However the maximum value of average that I can store is Double.MAX_VALUE ie 1.7976931348623157E308 after which the value becomes INFINITY. 但是,我可以存储的平均值的最大值是Double.MAX_VALUE,即1.7976931348623157E308,之后该值变为INFINITY。 How can I store values beyond the Double.MAX_VALUE in JAVA? 如何在JAVA中存储超出Double.MAX_VALUE的值?

您可以使用java.math.BigDecimal类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM