Unpredictability of the BigDecimal(double) constructor

前端 未结 6 2187
后悔当初
后悔当初 2020-12-01 18:27

I started using Sonar recently in a project, and i got a PMD rule broken about using the constructor new BigDecimal(double val). When i read the java documentat

6条回答
  •  抹茶落季
    2020-12-01 19:09

    You would use the double constructor when the data you want to work with already exists as a double value. Having to convert it to a string before converting it to BigDecimal would be a wasteful in that case.

提交回复
热议问题