Nikunj Banka
Nikunj Banka

Reputation: 11395

JAVA : Divide 2 bigdecimals and retain maximum number of digits after the decimal point

I want to divide 2 big decimals and retain maximum possible number of digits(say 1000 digits) in the non-terminating division result. What code shall I write to do this ?

Please note : Is it possible to have a high accuracy implementation as I am dealing with important data .

Upvotes: 3

Views: 2350

Answers (1)

rgettman
rgettman

Reputation: 178333

Use an overloaded divide method of BigDecimal that takes a scale as an argument; you can get an arbitary scale that way.

divide(BigDecimal divisor, int scale, RoundingMode roundingMode)

Upvotes: 4

Related Questions