java - Maximum precision below unlimited? -


i using bigdecimal make calculations. ran into:

java.lang.arithmeticexception:  non-terminating decimal expansion; no exact representable decimal result. 

the answer problem posted here: arithmeticexception: "non-terminating decimal expansion; no exact representable decimal result"

this means, there division unlimited decimals, bigdecimal tells me cannot calculate result exactly. avoid have call bigdecimal.setscale(something, rounding_mode);

edit:

the problem set maximum possible value. use mathcontext precision below unlimited (mathcontext(precision)) same problem occurrs there. there need value below mathcontext.unlimited...

does know how accomplish that?

moved second question to: why there no bigdecimal.setprecision() method?

thank you!

oliver

first question: there no such thing bigdecimal.unlimited. doesn't make sense. 1 less infinity? because docs don't explicitly mention default mathcontext of bigdecimal, have assume mathcontext.unlimited. seeing have repeating decimal, bigdecimal can't hold it, unlimited precision. instead, need arbitrarily pick value (say 100 or 1000 - have no idea using these numbers for). if care first, say, 15 decimal places, should never have rounding error if track first, say, 100.

second question: ask separate question it.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -