3 ms·
How'd you compare the unsimplified number then? How would it be obvious at the calling site what happens? Better explicitly compare only the simplified part (ag
by jstimpfle 10y ago
How'd you compare the unsimplified number then? How would it be obvious at the calling site what happens? Better explicitly compare only the simplified part (again, structurally).
- mcbits 10y agoThe most straightforward way would be to simplify during the equivalence check and maybe cache the value. Or maybe there is some trick to compare them without simplifying. Point is that you can have a notion of "equal but not identical". No doubt it's also possible to represent rationals with only structural equality, but I'd have to see two competing implementations to judge which is more intuitive to use.
- dllthomas 10y ago> Or maybe there is some trick to compare them without simplifying. a / b == c / d is equivalent to a * d = c * b, although whether that's a good approach depends on a lot of things.