user3456728
user3456728

Reputation: 21

How to handle numbers greater than Double.MAX_VALUE

I am continuously adding a stream of numbers and calculating their average in JAVA. However the maximum value of average that I can store is Double.MAX_VALUE i.e 1.7976931348623157E308 after which the value becomes INFINITY. How can I store values beyond the Double.MAX_VALUE in JAVA?

Upvotes: 2

Views: 3086

Answers (1)

Anton Danilov
Anton Danilov

Reputation: 1276

You may use java.math.BigDecimal class.

Upvotes: 2

Related Questions