Re: [numbers] Fraction() and Knuth 4.5.1 -- overflow, BigInteger, long, and rounding

2018-12-03 Thread Gilles
Hi Eric. On Mon, 3 Dec 2018 10:01:39 -0800, Eric Barnhill wrote: Does this mean that computations can "unpredictably" overflow (or throw an exception)? The ArithmeticUtils() methods mulAndCheck and addAndCheck throw exceptions if there is overflow during primitive operations. That is the "

Re: [numbers] Fraction() and Knuth 4.5.1 -- overflow, BigInteger, long, and rounding

2018-12-03 Thread Eric Barnhill
> > > Does this mean that computations can "unpredictably" overflow > (or throw an exception)? > The ArithmeticUtils() methods mulAndCheck and addAndCheck throw exceptions if there is overflow during primitive operations. That is the "check" part of the method name. > Is it acceptable, or should

Re: [numbers] Fraction() and Knuth 4.5.1 -- overflow, BigInteger, long, and rounding

2018-11-30 Thread Gilles
On Fri, 30 Nov 2018 15:56:54 -0800, Eric Barnhill wrote: Here is what I propose for the Fraction doc text regarding this issue: * Implement add and subtract. This algorithm is similar to that * described in Knuth 4.5.1. while making some concessions to * performance. Note Knuth 4

Re: [numbers] Fraction() and Knuth 4.5.1 -- overflow, BigInteger, long, and rounding

2018-11-30 Thread Eric Barnhill
Here is what I propose for the Fraction doc text regarding this issue: * Implement add and subtract. This algorithm is similar to that * described in Knuth 4.5.1. while making some concessions to * performance. Note Knuth 4.5.1 Exercise 7, which observes that * adding two fract

Re: [numbers] Fraction() and Knuth 4.5.1 -- overflow, BigInteger, long, and rounding

2018-11-09 Thread Eric Barnhill
Addendum to the above. In an exercise in the Knuth book Knuth does indeed state that "If the inputs are n-bit binary numbers, 2N+1 bits may be necessary to represent t." where t is a derived quantity that would take some time to explain. So that means in extreme cases, the needed precision to repr

Re: [numbers] Fraction() and Knuth 4.5.1 -- overflow, BigInteger, long, and rounding

2018-11-08 Thread Gary Gregory
I'm all for the Javadoc made to reflect the reality of the code. It is fine to have an additional section that points out Knuth and how we may want to change things as a hint or request to contributors. Gary On Wed, Nov 7, 2018 at 10:52 AM Eric Barnhill wrote: > I read Kunth's "Art of Computer

Re: [numbers] Fraction() and Knuth 4.5.1 -- overflow, BigInteger, long, and rounding

2018-11-08 Thread Gilles
Hi. On Wed, 7 Nov 2018 09:52:30 -0800, Eric Barnhill wrote: I read Kunth's "Art of Computer Programming 4.5.1" that is referenced many times in the doc as the guidance for the commons-math/commons-numbers Fraction class. It is an interesting read. Also, for all the times it is cited in the doc

[numbers] Fraction() and Knuth 4.5.1 -- overflow, BigInteger, long, and rounding

2018-11-07 Thread Eric Barnhill
I read Kunth's "Art of Computer Programming 4.5.1" that is referenced many times in the doc as the guidance for the commons-math/commons-numbers Fraction class. It is an interesting read. Also, for all the times it is cited in the doc, it is interesting that Fraction doesn't really use it as implem