# HG changeset patch
# User Thierry Monteil <sage at lma.metelu.net>
# 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

b

cdef class Rational(sage.structure.eleme 
2013  2013  sage: all([RDF(q) == RR(q) for q in Q]) 
2014  2014  True 
2015  2015  
 2016  Test that the conversion has correct rounding on simple rationals:: 
 2017  
 2018  sage: for p in [100..100]: 
 2019  ....: for q in [1..100]: 
 2020  ....: r = p/q 
 2021  ....: s, m, e = RDF(r).sign_mantissa_exponent() 
 2022  ....: if not abs(s*m*2^(e)  r) <= 2^(e1): 
 2023  ....: print 'Bug #14416 reappeared with rational', r 
 2024  
 2025  
2016  2026  At some point, the continued fraction and direct conversion 
2017  2027  to ``RDF`` should agree:: 
2018  2028  