Firstly, any time you convert from a double
to BigDecimal
you should take a step back and ask yourself whether you're really doing the right thing to start with. For example, if you've done this by parsing from a String
to a double
, then you should probably go straight from a String
to a BigDecimal
. I'm generally wary of this conversion, as it usually suggests someone is using an inappropriate type elsewhere.
Beyond that, they do different things: the constructor gives a BigDecimal
which represents the exact same number as the double
; valueOf
gives a BigDecimal
which represents the number given by the double
value's canonical string representation. They're simply different things, and you should know which one you want when you try to use one.
Given that I'd try to avoid getting into this situation to start with, it's hard to give examples of when each is more appropriate, but if you've unavoidably converting text to a double
, then lost the original text, but want to get back to that value, then using valueOf
is likely to give you a better result. If you've performed a bunch of arithmetic operations on double
values, then the constructor might be more appropriate. But it's really very context-sensitive, and as I say in most cases I'd probably choose a redesign rather than picking either option.