How to convert floats to human-readable fractions?

Posted by Swaroop C H on Stack Overflow See other posts from Stack Overflow or by Swaroop C H
Published on 2008-09-18T19:00:09Z Indexed on 2010/03/18 8:41 UTC
Read the original article Hit count: 604

Let's say we have 0.33, we need to output "1/3".
If we have "0.4", we need to output "2/5".

The idea is to make it human-readable to make the user understand "x parts out of y" as a better way of understanding data.

I know that percentages is a good substitute but I was wondering if there was a simple way to do this?

© Stack Overflow or respective owner

Related posts about algorithm

Related posts about numbers