mpn negation with borrow in
vincent at vinc17.org
Fri Aug 22 15:04:06 UTC 2014
On 2014-08-22 15:53:50 +0200, Torbjörn Granlund wrote:
> Vincent Lefevre <vincent at vinc17.org> writes:
> I was quite surprised to see that the mpn layer doesn't have a
> negation with borrow in,
> You will be even more surprised when you see that we don't have any
> (public) mpn functions with carry-in.
OK, I was thinking that it wasn't necessary for other functions
because the limb in mpn_add_1 and in mpn_sub_1 could be used as
a carry, but it's true that the case of mpn_add_n and mpn_sub_n
is similar to mpn_neg.
> * if the borrow is 0, use mpn_neg;
> * if the borrow is 1, use mpn_com.
> Is this the recommended way?
> That's how I'd do it. While mpn_com doesn't return "carry out", its
> value in this context is quite predictable.
Thanks, and yes, this is not a problem (and even with mpn_add_1
and mpn_neg, it seems that the carry out is redundant with other
information I have in my code -- but I can do a consistency check
for debugging purpose).
Vincent Lefèvre <vincent at vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
More information about the gmp-discuss