But the problem is that I am using doubles, so using modulus is out of the question.
That was my original idea though.
I guess I could convert the doubles to integers by multiplying them by 10^x depending on how many decimal places but I would like to not have to do that.
I guess I could convert the doubles to integers by multiplying them by 10^x depending on how many decimal places but I would like to not have to do that.
I suggest you do this, in fact, it's what I told my students to do when I made them implement a Fraction class in Ruby.
Converting doubles to fractions are tricky business, mostly because of the way that doubles are represented in binary. This is a long one, but it's a really good read.