simpleqt commented on PR #225:
URL: https://github.com/apache/commons-numbers/pull/225#issuecomment-6642259060

   One addition, since I had a second pass running when I wrote the above and 
it produced numbers rather than arguments.
   
   The equivalence is now measured, not just derived. An instrumented copy of 
the method (recording the tuple, behaviour unchanged) over the whole 
`commons-numbers-core` suite captured 150 distinct `(a, a1, b, a2)` tuples, and 
a public-API enumeration over integral high parts from `-2^63` upwards with a 
sweep of the low part, including the rounding-interval edges, plus random 
`ofSum`/`ofDifference`/`ofProduct`/`add`/`subtract`/`multiply`/`of(long)` 
chains produced 2,233,600 distinct tuples. The proposed check agrees with 
`Math.addExact` on all 2,233,750 of them, and `a1 + b` never overflows in any 
of them: `|a1|` is at most 2^62 while the largest `|b|` observed is 1024, from 
`DD.of(-0x1p63).subtract(DD.of(1024))`. That matches the structural bound 
rather than replacing it.
   
   On the clause: dropping `|| sum == 0` from your formulation is right, and 
dropping it from the `Math.addExact` formulation would have been a regression. 
The tuple that decides it is `DD.ofSum(-1.0, 1e-20)`, where the sum is 0 and 
`(sum ^ a) >= 0` is false, so the clause is what returns 0. Your check returns 
0 there without the clause, because `(0 ^ -1) & (0 ^ 1)` is positive. I have 
not re-added it.
   


-- 
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