Charcoal, 8140 bytes
≔I⪪S/θW﹪§θ±²§θ±¹⊞θι≧÷⌊θθ≔Xχ⌈E25⌕⮌X⁰↨§θ¹Iι⁰η¿﹪η§θ¹⪫…θ²θ≧÷⌈Φ⊕⌊θ∧ι¬⌈﹪θιθ¿﹪Xχφ§θ¹⪫θ/⁺÷§θ⁰§θ¹⭆I⁺η﹪×§θ⁰÷η§θ¹η⎇κι.I∕§θ⁰§θ¹ Try it online!Try it online! Link is to verbose version of code. Explanation: This
≔I⪪S/θ Input the fraction.
≧÷⌈Φ⊕⌊θ∧ι¬⌈﹪θιθ Reduce it to its lowest terms.
¿﹪Xχφ§θ¹ If the denominator is not a factor of 10¹⁰⁰⁰...
⪫θ/ ... output as a fraction, otherwise...
I∕§θ⁰§θ¹ output as a decimal.
81 bytes for the way overengineered version, which works with arbitrary precision positive integer inputs. I'll write a:
≔I⪪S/θW﹪§θ±²§θ±¹⊞θι≧÷⌊θθ≔Xχ⌈E25⌕⮌X⁰↨§θ¹Iι⁰η¿﹪η§θ¹⪫…θ²/⁺÷§θ⁰§θ¹⭆I⁺η﹪×§θ⁰÷η§θ¹η⎇κι. Try it online! Link is to verbose version golfed for the expected inputs laterof code. Explanation:
≔I⪪S/θ Input the fraction.
W﹪§θ±²§θ±¹⊞θι≧÷⌊θθ Reduce it to its lowest terms.
≔Xχ⌈E25⌕⮌X⁰↨§θ¹Iι⁰η Find a power of 10 that the denominator might be a factor of.
¿﹪η§θ¹⪫…θ²/ But if it isn't then just output the fraction.
⁺÷§θ⁰§θ¹⭆I⁺η﹪×§θ⁰÷η§θ¹η⎇κι. Convert the fraction to arbitrary precision decimal.