jpfroud
(Jean-Pierre Froud)
1
Rule java:S2111 recommends this as a compliant solution:
double d = 1.1;
BigDecimal bd1 = BigDecimal.valueOf(d);
But the result isn’t precise when using
double d = 1.0000000000000001
BigDecimal bd1 = BigDecimal.valueOf(d); -> 1.0
The only compliant solution should be new BigDecimal(String)
Colin
(Colin)
2
Hey there.
I’ve moved your post to the category on reporting false-positives.
Specifically, we’re missing what version of SonarQube you’re using.