So i want to be able to convert any decimal number into fraction. In both forms such as one without remainder like this: 3/5
or with remainder: 3 1/4
.
what i was doing is this..
lets say i have number .3435.
- Calculate amount of digits after decimals.
- multiply by 10 with power of the amount before number.
- then somehow find greatest common factor.
Now i don't know how to find GCF. And nor i know how to implement logic to find fraction that represents a number closely or in remainder form if exact fraction doesn't exists.
code i have so far: (testing)
x = 34/35;
a = x - x.toFixed();
tens = (10).pow(a.toString().length - 2);
numerator = tens * x;
denominator = tens;
I had researched all over the website and I did combine all code into one, Here you go!
This code is very easy to use! You can even put number in this function!
I came up with this for 16ths
One quick and easy way of doing it is