Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S2164: use BigDecimal if expected type is float #874

Open
algomaster99 opened this issue Aug 24, 2022 · 0 comments
Open

S2164: use BigDecimal if expected type is float #874

algomaster99 opened this issue Aug 24, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@algomaster99
Copy link
Member

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.

@algomaster99 algomaster99 added the enhancement New feature or request label Aug 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

1 participant