Changeset 7709:0afe8168cfd9 for sage/rings/real_rqdf.pyx
- Timestamp:
- 12/15/07 03:36:07 (5 years ago)
- Branch:
- default
- File:
-
- 1 edited
-
sage/rings/real_rqdf.pyx (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sage/rings/real_rqdf.pyx
r7554 r7709 120 120 isnan = 0 121 121 # 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) 123 125 mpfr_init2(cur, 53) 124 126 mpfr_init2(res, mpfr_get_prec(rr)) 125 mpfr_set_d(cur, d[0], GMP_RND Z)126 mpfr_sub(res, rr, cur, GMP_RND Z)127 mpfr_set_d(cur, d[0], GMP_RNDN) 128 mpfr_sub(res, rr, cur, GMP_RNDN) 127 129 # now we repeatedly find the most significant part of the remainder 128 130 for i from 1 <= i < 4: 129 d[i] = mpfr_get_d(res, GMP_RND Z)130 mpfr_set_d(cur, d[i], GMP_RND Z)131 mpfr_sub(res, res, cur, GMP_RND Z)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) 132 134 mpfr_clear(cur) 133 135 mpfr_clear(res) … … 290 292 if x.parent().prec() > 212: 291 293 return self(x) 292 294 293 295 return self._coerce_try(x, [RR()]) 294 296 … … 1076 1078 return K(repr(self)) 1077 1079 1078 def _mpfr_(self, K):1079 """1080 EXAMPLES:1081 sage: w = RQDF('2.345001').sqrt(); w1082 1.5313396096228948521281284258847499784832622626532043384729112771083 sage: w._mpfr_(RealField(212))1084 1.531339609622894852128128425884749978483262262653204338472911281085 sage: RealField(212)(w)1086 1.531339609622894852128128425884749978483262262653204338472911281087 sage: RealField(250)(w)1088 1.53133960962289485212812842588474997848326226265320433847291127700000000001089 """1090 return K(repr(self))1091 1092 1080 def _pari_(self): 1093 1081 """ … … 1239 1227 sage: w = RQDF(-2).sqrt(); w 1240 1228 1.41421356237309504880168872420969807856967187537694807317667974*I 1229 sage: w = RQDF('2.345001').sqrt(); w 1230 1.531339609622894852128128425884749978483262262653204338472911277 1241 1231 sage: w = RQDF(2).sqrt(all=True); w 1242 1232 [1.414213562373095048801688724209698078569671875376948073176679738,
Note: See TracChangeset
for help on using the changeset viewer.
