The BigRational code is a prototype on an experimental branch on a
project repository.
It should be understood that a prototype on an experimental branch on a
project repository does not have the same expectations, including
performance expectations, of code in the mainline repository, even
previewing or incubating code.
-Joe
On 8/3/2026 10:40 AM, David Alayachew wrote:
Perfect! That was exactly what I was looking for. Ty vm. What would
you say the chances of this making it in to the Standard Library are?
Also, since BigRational is normalized, that means that it depends
heavily on reduction. That means the
Perfect! That was exactly what I was looking for. Ty vm.
What would you say the chances of this making it in to the Standard
Library are?
Also, since BigRational is normalized, that means that it depends
heavily on reduction. That means the performance of gcd(), which I see
you are using, matters a ton. Would that be something you might
specialize in order to get good performance? I ask because I too
started with gcd, but found it to have some performance problems over
time. Nothing bad, but this is a number class, so that matters.
Thank you again, this is very insightful information!
On Mon, Aug 3, 2026, 11:20 AM Joseph D. Darcy <[email protected]>
wrote:
Slide 39 of the slide deck [1] corresponding to the talk, gives a link
https://github.com/openjdk/valhalla/tree/type-classes/
<https://urldefense.com/v3/__https://github.com/openjdk/valhalla/tree/type-classes/__;!!ACWV5N9M2RV99hQ!IOhmnML2O-DvBqaOqA0IHFqjwVLBEQ6pc63ABxO73GOrhKw1XZ6wMvcJfmbjbO1pvSvYwgQXwbR38lrwwJQdQgon$>
to a Valhalla branch hosting numerical experiments with type classes
[2]. Some of the numerical prototypes there predate JavaOne. One
of the
prototypes added after JavaOne was a BigRational type build on top of
BigIntegers:
https://github.com/openjdk/valhalla/blob/type-classes/src/java.base/share/classes/java/math/BigRational.java
<https://urldefense.com/v3/__https://github.com/openjdk/valhalla/blob/type-classes/src/java.base/share/classes/java/math/BigRational.java__;!!ACWV5N9M2RV99hQ!IOhmnML2O-DvBqaOqA0IHFqjwVLBEQ6pc63ABxO73GOrhKw1XZ6wMvcJfmbjbO1pvSvYwgQXwbR38lrwwAAlMzNb$>
Note a "Fraction" type would be different from a "Rational" type
since
Fraction would presumably distinguish between "1/2" and "2/4"
whereas a
Rational type would normalize these to 1/2.
-Joe
[1]
https://github.com/jddarcy/SpeakingArchive/blob/master/J1-2026-NumericalPaths.pdf
<https://urldefense.com/v3/__https://github.com/jddarcy/SpeakingArchive/blob/master/J1-2026-NumericalPaths.pdf__;!!ACWV5N9M2RV99hQ!IOhmnML2O-DvBqaOqA0IHFqjwVLBEQ6pc63ABxO73GOrhKw1XZ6wMvcJfmbjbO1pvSvYwgQXwbR38lrwwEM2FeCV$>
[2]
https://github.com/openjdk/valhalla/compare/lworld...type-classes
<https://urldefense.com/v3/__https://github.com/openjdk/valhalla/compare/lworld...type-classes__;!!ACWV5N9M2RV99hQ!IOhmnML2O-DvBqaOqA0IHFqjwVLBEQ6pc63ABxO73GOrhKw1XZ6wMvcJfmbjbO1pvSvYwgQXwbR38lrwwHBkpUVz$>
On 8/2/2026 1:18 PM, David Alayachew wrote:
> Hello @valhalla-dev <[email protected]>,
>
> I just recently watched the video from JavaOne 2026 by Joe Darcy
titled
> "Paths to New Numeric Types on the Java Platform". Here is a
link to it.
>
>
https://reddit.com/r/java/comments/1vdesc4/paths_to_new_numeric_types_on_the_java_platform/
<https://urldefense.com/v3/__https://reddit.com/r/java/comments/1vdesc4/paths_to_new_numeric_types_on_the_java_platform/__;!!ACWV5N9M2RV99hQ!IOhmnML2O-DvBqaOqA0IHFqjwVLBEQ6pc63ABxO73GOrhKw1XZ6wMvcJfmbjbO1pvSvYwgQXwbR38lrwwOLDT56e$>
>
> My question is about Fractions.
>
> The talk mentions that, if the mentioned features ever ship, we
can expect
> to see Float16, amongst others, added to the JDK. Might we see
Fractions
> join that list?
>
> I attempted my own version of this, titled BigNumber. Simply
put, it was a
> class with a BigInteger numerator and a BigInteger denominator.
Thus,
> arbitrary precision until you need to cast/convert to another
type. It was
> a really pleasant alternative to BigDecimal.
>
> Here is the class -- https://github.com/davidalayachew/BigNumber
<https://urldefense.com/v3/__https://github.com/davidalayachew/BigNumber__;!!ACWV5N9M2RV99hQ!IOhmnML2O-DvBqaOqA0IHFqjwVLBEQ6pc63ABxO73GOrhKw1XZ6wMvcJfmbjbO1pvSvYwgQXwbR38lrwwF8vMxOa$>
>
> I'm not at all proposing that my implementation is the right way
to do it.
> Furthermore, I can make my own if/when this feature drops. But I
wanted to
> ask if a fraction type like this might be added, as I suspect
that this
> would be a valuable tool for others too.
>
> Thank you for your time and consideration.
> David Alayachew