0
Iām having a problem with repeated decimals.
I managed to get a program take takes in a double and turn it to fraction. The problem with my program itās not display the repeated decimal one. Example .3333 Output 1/3 My output 33/100 Any ideas https://code.sololearn.com/cUr47b9YZ221/?ref=app
3 Answers
+ 2
Check 0.125, which should result in 1/8 but results in 3/25.
The problem is that you have a built-in resolution in line 34 which is rather coarse. A better strategy would be to take the number as a string, split at the decimal point and treat the integral and fractional parts individually as integers.
0
Technically, it could be 333/1000 or 3333/10000 and so on. Why not those variations but the 33/100 variation instead? 1/3 is an aproximation.
0
Slick im currently doing a project and its better doing it with lowest mixed fraction