Ignore:
Timestamp:
12/15/07 03:36:07 (5 years ago)
Author:
mabshoff@…
Branch:
default
Message:

Apply most of Paul's patch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sage/rings/real_rqdf.pyx

    r7554 r7709  
    120120    isnan = 0 
    121121    # The most significant double 
    122     d[0] = mpfr_get_d(rr, GMP_RNDZ)     
     122    # We use GMP_RNDN here, which guarantees an exact 
     123    # conversion if prec(rr) <= 4*53+3=215. 
     124    d[0] = mpfr_get_d(rr, GMP_RNDN) 
    123125    mpfr_init2(cur, 53) 
    124126    mpfr_init2(res, mpfr_get_prec(rr)) 
    125     mpfr_set_d(cur, d[0], GMP_RNDZ) 
    126     mpfr_sub(res, rr, cur, GMP_RNDZ) 
     127    mpfr_set_d(cur, d[0], GMP_RNDN) 
     128    mpfr_sub(res, rr, cur, GMP_RNDN) 
    127129    # now we repeatedly find the most significant part of the remainder  
    128130    for i from 1 <= i < 4: 
    129         d[i] = mpfr_get_d(res, GMP_RNDZ)  
    130         mpfr_set_d(cur, d[i], GMP_RNDZ) 
    131         mpfr_sub(res, res, cur, GMP_RNDZ) 
     131        d[i] = mpfr_get_d(res, GMP_RNDN) 
     132        mpfr_set_d(cur, d[i], GMP_RNDN) 
     133        mpfr_sub(res, res, cur, GMP_RNDN) 
    132134    mpfr_clear(cur) 
    133135    mpfr_clear(res) 
     
    290292            if  x.parent().prec() > 212: 
    291293                return self(x) 
    292                  
     294 
    293295        return self._coerce_try(x, [RR()]) 
    294296 
     
    10761078        return K(repr(self)) 
    10771079 
    1078     def _mpfr_(self, K): 
    1079         """ 
    1080         EXAMPLES: 
    1081             sage: w = RQDF('2.345001').sqrt(); w 
    1082             1.531339609622894852128128425884749978483262262653204338472911277 
    1083             sage: w._mpfr_(RealField(212)) 
    1084             1.53133960962289485212812842588474997848326226265320433847291128 
    1085             sage: RealField(212)(w) 
    1086             1.53133960962289485212812842588474997848326226265320433847291128 
    1087             sage: RealField(250)(w) 
    1088             1.5313396096228948521281284258847499784832622626532043384729112770000000000 
    1089         """ 
    1090         return K(repr(self)) 
    1091  
    10921080    def _pari_(self): 
    10931081        """ 
     
    12391227            sage: w = RQDF(-2).sqrt(); w 
    12401228            1.41421356237309504880168872420969807856967187537694807317667974*I 
     1229            sage: w = RQDF('2.345001').sqrt(); w 
     1230            1.531339609622894852128128425884749978483262262653204338472911277 
    12411231            sage: w = RQDF(2).sqrt(all=True); w 
    12421232            [1.414213562373095048801688724209698078569671875376948073176679738, 
Note: See TracChangeset for help on using the changeset viewer.