Ticket #14416: trac_14416_rounding_doctest-tm.patch

File trac_14416_rounding_doctest-tm.patch, 1.0 KB (added by tmonteil, 8 years ago)

Tested on sage 5.9.beta5, depends on #14448

  • sage/rings/rational.pyx

    # 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 
    20132013            sage: all([RDF(q) == RR(q) for q  in Q])
    20142014            True
    20152015
     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^(e-1):
     2023            ....:           print 'Bug #14416 reappeared with rational', r
     2024
     2025
    20162026        At some point, the continued fraction and direct conversion
    20172027        to ``RDF`` should agree::
    20182028