# Converting real numbers to rational format

I have a number of polynomials that are up to 200 terms long which I am copying and pasting into sage. They all have real-valued coefficients. When I try a and compute a Groebner basis I get the error:

```
AttributeError: 'sage.rings.real_mpfr.RealNumber' object has no attribute 'divides'
```

Is there a way to automatically approximate these coefficients as exact rationals? I could do it view convoluted string parsing in python but would prefer if there is a built in method in python. As a toy example, the following does not work (note the .1 in the first term)

```
R = PolynomialRing(QQ,'q0,q1,q2,q3,q4')
I = Ideal(
1522732369974.1*q0^3-8*q1^3+3924472*q0^2*q1-142784271977*q0^2*q2,
1423*q3^2*q4-1396461224121*q3^2+57684122*q0*q1*q2+q0*q1*q3+294*q3*q4^2
)
B = I.groebner_basis(); B
```

While if I represent the value as a fraction everything works fine.

```
R = PolynomialRing(QQ,'q0,q1,q2,q3,q4')
I = Ideal(
15227323699741/10*q0^3-8*q1^3+3924472*q0^2*q1-142784271977*q0^2*q2,
1423*q3^2*q4-1396461224121*q3^2+57684122*q0*q1*q2+q0*q1*q3+294*q3*q4^2
)
B = I.groebner_basis(); B
```

My actual use case has many terms, all of which have many more decimal places that this example so manually adjusting things would take a substantial amount of time.