S2164: use `BigDecimal` if expected type is `float`
Opened this issue · 0 comments
algomaster99 commented
As of now, the processor for S2164
is incomplete because of the following case:
float a = 16777216.0f;
float b = 1.0f;
- float c = a + b; // Noncompliant, yields 1.6777216E7 not 1.6777217E7
+ float c = (double) a + (double) b;
See #570 for more details.
However, it can be made fully-fixable if we convert float
to java.math.BigDecimal
and cast one of the operands to BigDecimal
as well.