supposing I have a decimal like
0.30000000000000027
What would be the best algorithm to know the same number expressed as a fraction
So given certain x
find y
that satisfies x=1/y
in c or haskell
I was thinking
1/3> 0.30 >1/4
Iterating left and right side til one of them converges and >
becomes =
so first iteration would look like
1/1 > 0.30000000000000027 > 1/somethinghere
1/2 > 0.30000000000000027 > 1/increase or decrease this
1/3 > 0.30000000000000027 ...
I want to clarify that I could easily do
0.30000000000000027 = 30000000000000027/ 10^17
but I want to do
0.30000000000000027 = 1/x
In c or haskell