From 1416952cc1daec82130fbcc07ea22baf62975ceb Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Mon, 14 Apr 2025 10:39:25 +0200 Subject: [PATCH] Java: update inspection description GitOrigin-RevId: 8d3e6db7b5e6bc171f243e6aef53b4bd02d69b20 --- .../UnpredictableBigDecimalConstructorCall.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/java/java-impl/resources/inspectionDescriptions/UnpredictableBigDecimalConstructorCall.html b/java/java-impl/resources/inspectionDescriptions/UnpredictableBigDecimalConstructorCall.html index 8c59c93ba5aa..1c9b4a2f6d63 100644 --- a/java/java-impl/resources/inspectionDescriptions/UnpredictableBigDecimalConstructorCall.html +++ b/java/java-impl/resources/inspectionDescriptions/UnpredictableBigDecimalConstructorCall.html @@ -1,12 +1,12 @@ Reports calls to BigDecimal constructors that accept a double value. -These constructors produce BigDecimal that is exactly equal to the supplied double value. -However, because doubles are encoded in the IEEE 754 64-bit double-precision binary floating-point format, the exact value can be unexpected. -

For example, new BigDecimal(0.1) yields a BigDecimal object. Its value is - 0.1000000000000000055511151231257827021181583404541015625 - which is the nearest number to 0.1 representable as a double. - To get BigDecimal that stores the same value as written in the source code, +These constructors produce BigDecimal that is equal to the supplied double value. +However, because doubles are encoded in the IEEE-754 64-bit double-precision binary floating-point format, the exact value can be unexpected. +

For example, new BigDecimal(0.1) yields a BigDecimal object with value + 0.1000000000000000055511151231257827021181583404541015625, + which is the nearest number to 0.1 representable as a double. + To get a BigDecimal that contains the expected value 0.1, use either new BigDecimal("0.1") or BigDecimal.valueOf(0.1).

Example: