Why is the Bigdecimal(double d) construction still around?

后端 未结 3 440
广开言路
广开言路 2020-12-11 15:20

I\'ve noticed substantial pain over this constructor (even here on Stack Overflow). People use it even though the documentation clearly states:

Th

3条回答
  •  孤城傲影
    2020-12-11 15:47

    That particular constructor, like all floating point operations, is an approximation. It's not really broken, it just has shortcomings.
    Just do your research, approach it with care, and you won't get any surprises. You run into exactly the same thing when assigning decimal literals to doubles/floats.

提交回复
热议问题