On Wed, 3 Mar 2021 07:20:03 GMT, Joe Darcy <da...@openjdk.org> wrote:

> I considered @stuart-marks previous suggestion during the code review of 
> JDK-8261123 to include a more explicit discussion of why, say, different 
> representations of 2 should not be regarded as equivalent. After 
> contemplating several alternatives, I didn't find anything simpler than 
> Stuart's 2/3 example so I used that as seen in the diff.
> 
> A short digression, BigDecimal supports both fixed-point style and 
> floating-point style rounding. Floating-point rounding primarily replies on 
> the number of precision digits, regards of their scale, while fixed-point 
> style rounding prioritizes the scale. The number of digits of eventual output 
> is a function of number number of digits in the inputs and the number of 
> precision digits in a floating-point style rounding. A floating-point style 
> rounding has a preferred scale, rather than a fixed scale based on the 
> inputs. The fixed-point style divide method used in the example has a scale 
> based on the dividend, allowing a relatively simple expression to show a 
> distinction between 2.0 and 2.00.

Marked as reviewed by smarks (Reviewer).

src/java.base/share/classes/java/math/BigDecimal.java line 3155:

> 3153:      * {@code new BigDecimal("2.00").divide(BigDecimal.valueOf(3),
> 3154:      * HALF_UP)} which evaluates to 0.<b>6</b>7.
> 3155:      *

Should this be in an `@apiNote`?

I'm not sure adding the boldface 0.**6**7 is helpful; 0.7 is self-evidently 
unequal to 0.67.

-------------

PR: https://git.openjdk.java.net/jdk/pull/2804

Reply via email to