Ticket #11666: trac_11666_reduce_precision_max.patch

File trac_11666_reduce_precision_max.patch, 1.6 KB (added by vbraun, 7 years ago)

Updated patch to limit precision at 231-257 Updated patch to limit precision at 231-257 Updated patch to limit precision at 231-257

  • sage/rings/real_mpfr.pyx

    # HG changeset patch
    # User Volker Braun <vbraun@stp.dias.ie>
    # Date 1330020782 28800
    # Node ID 3aec8988d4cb8214d69933ea6011c05d4a05bdd7
    # Parent  a202ee88c02e9765b6b8e4f4b34e4b6ea59944c0
    Trac #11666: Upgrade MPFR to 3.1.0
    
    Reduce the maximal precision to be slightly below INT_MAX on 32bit
    
    diff --git a/sage/rings/real_mpfr.pyx b/sage/rings/real_mpfr.pyx
    a b  
    184184    """
    185185    return MPFR_PREC_MIN
    186186
    187 cdef int MY_MPFR_PREC_MAX = 2147483647
     187# see Trac #11666 for the origin of this magical constant
     188cdef int MY_MPFR_PREC_MAX = 2147483647 - 256   # = 2^31-257
    188189def mpfr_prec_max():
    189190    """
    190191    TESTS::
    191192
    192         sage: R = RealField(2147483647)
     193        sage: from sage.rings.real_mpfr import mpfr_prec_max
     194        sage: mpfr_prec_max()
     195        2147483391
     196        sage: R = RealField(2^31-257)
    193197        sage: R
    194         Real Field with 2147483647 bits of precision
    195         sage: R = RealField(2147483648)
     198        Real Field with 2147483391 bits of precision
     199        sage: R = RealField(2^31-256)
    196200        Traceback (most recent call last):
    197201        ...
    198         OverflowError: ... too large to convert to C long   # 32-bit
    199         OverflowError: ... too large to convert to int      # 64-bit
     202        ValueError: prec (=2147483392) must be >= 2 and <= 2147483391.
    200203    """
    201204    global MY_MPFR_PREC_MAX
    202     # We use 2^31-1 as the largest precision, since 2^31 is not representable
    203     # as a 32-bit int
    204205    return MY_MPFR_PREC_MAX
    205206
    206207#*****************************************************************************