Why no Fraction type in Scala?


#1

Seems to be a core class that could be in the math library. Am I missing something? I just want a class where I have two longs, a numerator and denominator and has defined math operations on the type. It just seems odd that I have to import commons-lang3 math for such a fundamental type.


#2

Rationals have weird behavior regarding precision and wrapping. Most languages don’t include them in their core libraries, despite fractions being common grade-school mathematics. It wouldn’t really hurt to have one with well-defined behavior (or two: one with arbitrary precision and one with Long and/or Int), but nobody’s gotten around to it, and at this point having in an external math library would probably make more sense.

After all, there are also no vectors (2 or 3 element), no error function, no quadratic formula, etc. etc…


#3

Use magnificent spire library for bunch of school-grade algebra.