Ciao, Il Mer, 29 Aprile 2015 10:49 am, t...@gmplib.org ha scritto: > ni...@lysator.liu.se (Niels Möller) writes:
mp_limb_t mpn_neg (mp_ptr rp, mp_srcptr up, mp_size_t n) { /* Low zero limbs are unchanged by negation. */ while (*up == 0) { *rp = 0; if (!--n) /* All zero */ return 0; ++up; ++rp; } /* First non-zero limb is negated. */ *rp = - *up; /* Higher limbs get complemented. */ if (--n) mpn_com (++rp, ++up, n); return 1; } Looks much better than mine! (I micro-optimised increments, moving them after the possibly returning branches) Regards, m -- http://bodrato.it/ _______________________________________________ gmp-devel mailing list gmp-devel@gmplib.org https://gmplib.org/mailman/listinfo/gmp-devel