Skip to content

Fix BigDecimalLiteralDouble for boxed floating-point values#5787

Open
codingkiddo wants to merge 1 commit into
google:masterfrom
codingkiddo:fix/bigdecimal-boxed-floating-point
Open

Fix BigDecimalLiteralDouble for boxed floating-point values#5787
codingkiddo wants to merge 1 commit into
google:masterfrom
codingkiddo:fix/bigdecimal-boxed-floating-point

Conversation

@codingkiddo
Copy link
Copy Markdown

Fixes #5759.

Summary

BigDecimalLiteralDouble reported precision-loss diagnostics for direct double / float literals passed to BigDecimal(double), but it missed boxed Double / Float values.

For example:

Double boxedD = 0.1;
new BigDecimal(boxedD);

This still invokes the BigDecimal(double) constructor after unboxing, so it has the same precision-loss problem as passing a primitive floating-point literal directly.

Changes

  • Added regression coverage for boxed Double / Float arguments.
  • Updated BigDecimalLiteralDouble to detect boxed floating-point arguments consistently with primitive floating-point arguments.
  • Kept the existing suggested fix behavior limited to direct literal cases, where the replacement source is safe to construct.

Test

mvn -pl core -Dtest=BigDecimalLiteralDoubleTest test

Result:

Tests run: 3, Failures: 0, Errors: 0, Skipped: 0
BUILD SUCCESS

@google-cla
Copy link
Copy Markdown

google-cla Bot commented May 9, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Signed-off-by: Vinod Kumar <codingkiddo@gmail.com>
@codingkiddo codingkiddo force-pushed the fix/bigdecimal-boxed-floating-point branch from 36ed471 to 7c7cc60 Compare May 9, 2026 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BigDecimalLiteralDouble false negative for the boxed value

1 participant