Using floats turned out to be a bad idea, as it broke subtely if the needed precision was too large. This PR replaces the implementation with one that uses fractions and stores them in the database as two integers.