Fractions vs decimals

Fractions vs decimals

I need to program a form where if a user enters a decimal number a fraction is displayed, and vice versa.  How can this be programmed? There does not seem to be generic support for fractions. Thanks!