new BigDecimal(double) should not be used
org.openrewrite.staticanalysis.BigDecimalDoubleConstructorRecipeorg.openrewrite.recipe:rewrite-static-analysisUse of new BigDecimal(double) constructor can lead to loss of precision. Use BigDecimal.valueOf(double) instead.
For example writing new BigDecimal(0.1) does not create a BigDecimal which is exactly equal to 0.1, but it is equal to 0.1000000000000000055511151231257827021181583404541015625. This is because 0.1 cannot be represented exactly as a double (or, for that matter, as a binary fraction of any finite length). BigDecimal.valueOf avoids this by converting through a string representation, preserving the value you actually intended.
Usage
This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe org.openrewrite.staticanalysis.BigDecimalDoubleConstructorRecipeIf the recipe isn’t available locally, install it with:
mod config recipes jar install org.openrewrite.recipe:rewrite-static-analysis:2.40.0Data tables
Structured output this recipe can produce.
- Source files that had resultsSource files that were modified by the recipe run.
org.openrewrite.table.SourcesFileResults - Source files that had search resultsSearch results that were found during the recipe run.
org.openrewrite.table.SearchResults - Source files that errored on a recipeThe details of all errors produced by a recipe run.
org.openrewrite.table.SourcesFileErrors - Recipe performanceStatistics used in analyzing the performance of recipes.
org.openrewrite.table.RecipeRunStats