# HG changeset patch
# User Thierry Monteil
# Date 1365979232 -7200
# Node ID 2db0b288ef471dc07e6ba63272821bbfa910b093
# Parent 1a3c62633a7c010eb5a73677781274a6a49859c8
#14416: Add doctest about rounding in the conversion from QQ to RDF.
diff --git a/sage/rings/rational.pyx b/sage/rings/rational.pyx
--- a/sage/rings/rational.pyx
+++ b/sage/rings/rational.pyx
@@ -2013,6 +2013,16 @@ cdef class Rational(sage.structure.eleme
sage: all([RDF(q) == RR(q) for q in Q])
True
+ Test that the conversion has correct rounding on simple rationals::
+
+ sage: for p in [-100..100]:
+ ....: for q in [1..100]:
+ ....: r = p/q
+ ....: s, m, e = RDF(r).sign_mantissa_exponent()
+ ....: if not abs(s*m*2^(e) - r) <= 2^(e-1):
+ ....: print 'Bug #14416 reappeared with rational', r
+
+
At some point, the continued fraction and direct conversion
to ``RDF`` should agree::