Hello Joe, Thank you for the clarification.
What do you think about using BigBinary to solve the problem of a calculation class with higher precision. BigBinary implements arbitrary precision binary floating-point numbers and arithmetic operations on them. Although it rounds, the precision and rounding direction are controlled. It seems to me that binary floating-point numbers are more natural than decimal for scientific applications. Should such a class be in the JDK or outside? If you don't think that BigBinary is appropriate, then let me ask some other questions. IEEE 754-2008 defines three basic binary formats: Binary32, Binary64, Binary128 . Binary32 and Binary64 are already known in JDK as Float and Double (with rounding to nearest even). Should there be a software emulation of Binary128 in JDK (as a class with two private long fields)? Should the JDK have a class with static methods that implement arithmetic operations on floats and doubles with directed rounding like http://java.net/projects/projectfortress/sources/sources/content/ProjectFortress/src/com/sun/fortress/numerics/DirectedRounding.java ? Is there a chance that Binary128 or DirectedRounding methods would be internalized in hotspot? These questions are important to me because I am working on an interval arithmetic library http://kenai.com/projects/jinterval/ and could use these new classes. I understand that the addition of numerical features to the JDK is closed. However, if there is a chance to add any new classes, I'd be glad to contibute to their development. Cheers, -Dima On Fri, Jan 6, 2012 at 2:46 AM, Joe Darcy <joe.da...@oracle.com> wrote: > Hello, > > > On 1/1/2012 8:54 AM, Tom Eugelink wrote: >> >> >> Hello guys, >> >> I was wondering if it was of any interest to OpenJFX to have a calculation >> class that does not round. I've got "Fraction" laying around, which does >> math using two BigIntegers, so it never even rounds. The API is roughly >> equivalent to BigDecimal, so you have methods like add, divide, etc. >> >> Any interest in adding such a class to Java? >> > > The BigDecimal class can already preform exact computations. To get exact > behavior, use the version of add, subtract, etc. that takes a single > BigDecimal argument or the version that takes a BigDecimal argument and a > MathContext argument and pass a MathContext object with a precision of 0. > Of the four basic arithmetic operations, the most interesting operation is > divide since it can result in infinite inputs (fractions that are > non-terminating in decimal) from finite inputs while the other operations > cannot. > > In terms of its representation, BigDecimal class uses a floating-point style > scaled representation so that very large or very small numbers that are > low-precision don't use a lot of storage. > > When doing general computations, there is a need to round result > periodically to avoid unbounded growth in the sizes of the numbers being > operated on. BigDecimal supports various rounding operations, including > rounding to a given number of places after the decimal point and rounding to > a given number of total digits. These styles of rounding are relatively > easy to understand, but still quite vexing for numerical analysis. > > The rounding options I'm familiar with for rational packages are fixed slash > vs floating-slash, that is, given constraints on the sizes of the numerator > and denominator, return the nearest fraction to the exact result. AFAIK, > such system are less studied if not more difficult to work with than > traditional rounding. > > In short, while there would be some use cases, without additional > justification I don't see the need to add a rational number package to the > JDK. > > Cheers, > > -Joe >