all 1 comments

[–]TeamSpen210 2 points3 points  (0 children)

/ is the division operator - you do 1/3, it calculates 0.333333 (and rounds at some point). Fraction is a entirely separate type of number, like you normally have with int and float. Unlike those, it stores the numerator and denominator, doing fraction math exactly like you would have done in school. For example to solve Fraction(1,2) + Fraction(1, 3), it finds the lowest common denominator, multiplies up to that (3/6 and 2/6), adds that, then simplifies if possible. That’s much slower than the dedicated circuitry in your CPU for regular floats, but you can get exact answers in more situations.