function that gives the fraction for a number

Do you know any function that given a real number x, gives us the integers that are the numerator and denominator of its fraction?

I have a real x, and I'd like to know how it's written as a fraction. That is, I have the value for x, and I want to know the denominator d and the numerator n such as x = n/d.

If you know such a function, as well as the library that contains it, thanks.


And sorry if my English isn't good xD
If you can find such a function, you'll break mathematics.
f(√2)=?
Topic archived. No new replies allowed.