-
Rational numbers
I'm looking for a class that represents a rational number. But I need a really good one, it should support shortening itself to the smallest possible representation and the 4 basic arithmetic operations.
I have written one myself, but it suffers from the lack of precision. It creates an OutOfMemoryError if one of the two integers gets as large as ~ one billion (yeah, lack of precision :rolleyes: ). Problem is that this can actually happen when inverting matrices, which is what I do.
Any help or info appreciated. An algorithm to shorten the number without allocating one GB of data would suffice (happens to me sometimes...).
Thanks in advance.