From 8b1e9c4dd1fd12e3b85750a5c0044b54ced216c7 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 12 Feb 2026 13:45:48 +0100 Subject: Add subtraction and addition with carry/borrow and add abs_diff MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libj2_j2i_add_j2i.3 | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'libj2_j2i_add_j2i.3') diff --git a/libj2_j2i_add_j2i.3 b/libj2_j2i_add_j2i.3 index df0debd..b303be2 100644 --- a/libj2_j2i_add_j2i.3 +++ b/libj2_j2i_add_j2i.3 @@ -23,6 +23,9 @@ int \fBlibj2_j2i_add_j2i_overflow_p\fP(const struct libj2_j2i *\fIa\fP, const st int \fBlibj2_j2i_add_ji_overflow_p\fP(const struct libj2_j2i *\fIa\fP, intmax_t \fIb\fP); int \fBlibj2_ji_add_j2i_overflow_p\fP(intmax_t \fIa\fP, const struct libj2_j2i *\fIb\fP); +void \fBlibj2_j2i_add_j2i_carry\fP(struct libj2_j2i *\fIa\fP, const struct libj2_j2i *\fIb\fP, int *\fIc\fP); +void \fBlibj2_j2i_add_j2i_to_j2i_carry\fP(const struct libj2_j2i *\fIa\fP, const struct libj2_j2i *\fIb\fP, struct libj2_j2i *\fIr\fP, int *\fIc\fP); + void \fBlibj2_j2u_add_j2u\fP(struct libj2_j2u *\fIa\fP, const struct libj2_j2u *\fIb\fP); void \fBlibj2_j2u_add_j2u_to_j2u\fP(const struct libj2_j2u *\fIa\fP, const struct libj2_j2u *\fIb\fP, struct libj2_j2u *\fIr\fP); void \fBlibj2_j2u_add_ju\fP(struct libj2_j2u *\fIa\fP, uintmax_t \fIb\fP); @@ -40,6 +43,9 @@ int \fBlibj2_j2u_add_j2u_overflow_p\fP(const struct libj2_j2u *\fIa\fP, const st int \fBlibj2_j2u_add_ju_overflow_p\fP(const struct libj2_j2u *\fIa\fP, uintmax_t \fIb\fP); int \fBlibj2_ju_add_j2u_overflow_p\fP(uintmax_t \fIa\fP, const struct libj2_j2u *\fIb\fP); +void \fBlibj2_j2u_add_j2u_carry\fP(struct libj2_j2u *\fIa\fP, const struct libj2_j2u *\fIb\fP, int *\fIc\fP); +void \fBlibj2_j2u_add_j2u_to_j2u_carry\fP(const struct libj2_j2u *\fIa\fP, const struct libj2_j2u *\fIb\fP, struct libj2_j2i *\fIr\fP, int *\fIc\fP); + void \fBlibj2_j2i_sat_add_j2i\fP(struct libj2_j2i *\fIa\fP, const struct libj2_j2i *\fIb\fP); void \fBlibj2_j2i_sat_add_j2i_to_j2i\fP(const struct libj2_j2i *\fIa\fP, const struct libj2_j2i *\fIb\fP, struct libj2_j2i *\fIr\fP); void \fBlibj2_j2i_sat_add_ji\fP(struct libj2_j2i *\fIa\fP, intmax_t \fIb\fP); @@ -84,6 +90,28 @@ with word .B overflow in their name), detect arithmetic overflow. .PP +The +.BR libj2_j2i_add_j2i_carry () +and +.BR libj2_j2i_add_j2i_to_j2i_carry () +fuctions add +.IR *c , +which must be +1, -1, or 0, +to the result, and sets +.I *c +to +1 on positive overflow, +-1 on negative overflow, and 0 otherwise. +.PP +.BR libj2_j2u_add_j2u_carry () +and +.BR libj2_j2u_add_j2u_to_j2u_carry () +fuctions add +.IR *c , +which must be 1 or 0, +to the result, and sets +.IR *c +to 1 on overflow, and 0 otherwise. +.PP The result is truncated to the least significant bits, as many as can be stored, in case of overflow; that is, modular arithmetics is used. However, the @@ -155,6 +183,15 @@ and .BR libj2_ju_sat_add_j2u_to_j2u () functions were added in version 1.1 of .BR libj2 . +.PP +The +.BR libj2_j2i_add_j2i_carry (), +.BR libj2_j2i_add_j2i_to_j2i_carry (), +.BR libj2_j2u_add_j2u_carry (), +and +.BR libj2_j2u_add_j2u_to_j2u_carry () +functions were added in version 1.2 of +.BR libj2 . .SH SEE ALSO .BR libj2 (7), -- cgit v1.2.3-70-g09d2