# Revision history [back]

sage: type(1/30)
<type 'sage.rings.rational.Rational'>
sage: type(1/3e1)
<type 'sage.rings.real_mpfr.RealNumber'>


In your first thing, you're approximating a rational arbitrarily. In the second, you're approximating the (default 53 bit, I think you're right) "real" number closest to 1/30 with garbage after that many bits, as you suspect.

sage: a = 1/3e1
sage: a
0.0333333333333333
sage: a.prec()
53
sage: a.n(100)
0.033333333333333332870740406406


But in the last one you are doing the same as this, more or less:

sage: b = 3e1
sage: 3e1.n(digits=30)
30.0000000000000000000000000000
sage: type(3e1.n(digits=30))
<type 'sage.rings.real_mpfr.RealNumber'>
sage: (3e1.n(digits=30)).prec()
103
sage: 1/(3e1.n(digits=30))
0.0333333333333333333333333333333


which seems appropriate to me, since 30 can be represented exactly in binary, but 1/30 can't.