Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
Date: Thu, 24 Feb 2005 12:40:27 +0100 From: Vincent Lefevre To: , , , Subject: [patch to mpn_dc_sqrtrem] Content-Disposition: inline The patch was incorrect. I've added the comment "signed" for c, and missing parentheses here: c -= (int) ((l == h) ? b : mpn_sub_1 (np + 2 * l, np + 2 * l, 1, b)); so that the cast is applied to the result and not to (l == h). --- sqrtrem.c 2002-04-18 19:20:28.000000000 +0200 +++ sqrtrem.c.new 2005-01-28 17:10:32.785658988 +0100 @@ -170,7 +170,8 @@ mpn_dc_sqrtrem (mp_ptr sp, mp_ptr np, mp_size_t n) { mp_limb_t q; /* carry out of {sp, n} */ - int c, b; /* carry out of remainder */ + mp_limb_t b; + int c; /* carry out of remainder, signed */ mp_size_t l, h; ASSERT (np[2 * n - 1] >= GMP_NUMB_HIGHBIT / 2); @@ -185,21 +186,21 @@ if (q != 0) mpn_sub_n (np + 2 * l, np + 2 * l, sp + l, h); q += mpn_divrem (sp, 0, np + l, n, sp + l, h); - c = sp[0] & 1; + c = (int) (sp[0] & (mp_limb_t) 1); mpn_rshift (sp, sp, l, 1); sp[l - 1] |= (q << (GMP_NUMB_BITS - 1)) & GMP_NUMB_MASK; q >>= 1; if (c != 0) - c = mpn_add_n (np + l, np + l, sp + l, h); + c = (int) mpn_add_n (np + l, np + l, sp + l, h); mpn_sqr_n (np + n, sp, l); b = q + mpn_sub_n (np, np, np + n, 2 * l); - c -= (l == h) ? b : mpn_sub_1 (np + 2 * l, np + 2 * l, 1, b); + c -= (int) ((l == h) ? b : mpn_sub_1 (np + 2 * l, np + 2 * l, 1, b)); q = mpn_add_1 (sp + l, sp + l, h, q); if (c < 0) { - c += mpn_addmul_1 (np, sp, n, 2) + 2 * q; - c -= mpn_sub_1 (np, np, n, 1); + c += (int) (mpn_addmul_1 (np, sp, n, 2) + 2 * q); + c -= (int) mpn_sub_1 (np, np, n, 1); q -= mpn_sub_1 (sp, sp, n, 1); } } -- Vincent Lefèvre - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / SPACES project at LORIA