Because ratio values reduce to lowest terms and, for integral values where the lowest term is N/1, are auto-converted to BigInts (and formerly Longs), the current behavior of clojure.core/numerator and clojure.core/denominator yield unexpected results.
It's confusing to not support numerator and denominator on integer types as this requires you to always check ratio? before invoking them.
Proposed: Extend numerator and denominator to also work on integer types (long, BigInt, BigInteger) by routing to overloaded methods on Numbers for the desired types.
Patch: clj-1435.patch
Screened by: Alex Miller
Questions from screening for Rich:
1. numerator and denominator are tagged as returning java.math.BigInteger (not clojure.lang.BigInt) and that's what I followed in the patch. Seems like maybe that should be BigInt though? Not sure on what basis to make that decision.
2. Should numerator and denominator accept both BigInteger and BigInt?
Can I give it love? If there's a direction that we can agree on, I'd be happy to create the patch.
I've screeened the patch that's here already?
The new versions of numerator and denominator after this patch was applied perform reflective calls. Is that expected?
Created ticket CLJ-2408 to make the question more prominent than a comment on a closed ticket.
Patch reverted