Convert Java Number to BigDecimal : best way -


i looking best way convert number bigdecimal.

is enough?

number number; bigdecimal big = new bigdecimal(number.tostring()); 

can lose precision tostring() method ?

this fine, remember using constructor of bigdecimal declare value can dangerous when it's not of type string. consider below...

bigdecimal valdouble = new bigdecimal(0.35); system.out.println(valdouble); 

this not print 0.35, infact be...

0.34999999999999997779553950749686919152736663818359375 

i'd solution safest because of that.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -