Question about mpn_add_n underlying generic implementation

David Gillies daggillies at gmail.com
Sat Jan 18 02:22:19 UTC 2014


They're carry flags



On Fri, Jan 17, 2014 at 6:15 PM, Grzegorz Szpetkowski <
gszpetkowski at gmail.com> wrote:

> Hi all,
>
> I have read manual (mostly) and I am trying to understand following code
> within mpn/generic/add_n.c:
>
>   mp_limb_t ul, vl, sl, rl, cy, cy1, cy2;
>
>   ASSERT (n >= 1);
>   ASSERT (MPN_SAME_OR_INCR_P (rp, up, n));
>   ASSERT (MPN_SAME_OR_INCR_P (rp, vp, n));
>
>   cy = 0;
>   do
>     {
>       ul = *up++;
>       vl = *vp++;
>       sl = ul + vl;
>       cy1 = sl < ul;
>       rl = sl + cy;
>       cy2 = rl < sl;
>       cy = cy1 | cy2;
>       *rp++ = rl;
>     }
>   while (--n != 0);
>
> There is some preprocessor condition for GMP_NAIL_BITS, but as I found it's
> disabled in configuration by default and I am sure that my build does not
> have it enabled. Essentially what is the purpose of these cy1 and cy2
> variables ? What I already understand is that examined limbs (in reversed
> order) are just effectively primitive integers like unsigned int, for
> example::
>
> #ifdef __GMP_SHORT_LIMB
> typedef unsigned int            mp_limb_t;
>
> G. Sz.
> _______________________________________________
> gmp-discuss mailing list
> gmp-discuss at gmplib.org
> https://gmplib.org/mailman/listinfo/gmp-discuss
>



-- 
David Gillies
San Jose
Costa Rica


More information about the gmp-discuss mailing list