<p>Let's say we have <code>0.33</code>, we need to output <code>1/3</code>. <br />
If we have <code>0.4</code>, we need to output <code>2/5</code>.</p>

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

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

You might want to read
What Every Computer Scientist Should Know about Floating Point Arithmetic
.
You'll have to specify some precision by multiplying by a large number:
```
```
3.141592 * 1000000 = 3141592
```
```
then you can make a fraction:
```
```
3 + (141592 / 1000000)
```
```
and reduce via GCD...
```
```
3 + (17699 / 125000)
```
```
but there is no way to get the
intended
fraction out. You might want to
always
use fractions throughout your code instead --just remember to reduce fractions when you can to avoid overflow!