insaf021 commented on code in PR #359:
URL: https://github.com/apache/commons-math/pull/359#discussion_r4731054944


##########
commons-math-legacy-core/src/test/java/org/apache/commons/math4/legacy/core/dfp/DfpTest.java:
##########
@@ -116,6 +116,24 @@ public void testLongConstructor() {
         Assert.assertEquals("9223372036854775807.", new Dfp(field, 
Long.MAX_VALUE).toString());
     }
 
+    @Test
+    public void testLongConstructorBeyondPrecision() {
+        // 4 radix digits (16 decimal digits) cannot hold every long
+        final DfpField small = new DfpField(10);

Review Comment:
   Raised #362 for it. The parser keeps a single decimal digit past the 
mantissa and hands `round()` `digit * 1000`, so a remainder of 5678 arrives as 
an exact 5000 and everything below that first digit never reaches the tie test 
at all; that also means `FLAG_INEXACT` was being missed. It now keeps a full 
radix digit of remainder plus a sticky bit for whatever is dropped below it. 
Cross-checked against `BigDecimal` half-even over 80k generated values across 7 
field sizes: 7665 disagreed before, none after.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to