diff options
| author | Mattias Andrée <m@maandree.se> | 2026-02-12 13:45:48 +0100 |
|---|---|---|
| committer | Mattias Andrée <m@maandree.se> | 2026-02-12 13:45:48 +0100 |
| commit | 8b1e9c4dd1fd12e3b85750a5c0044b54ced216c7 (patch) | |
| tree | fbf6b79555576e9005eeb84c0b605985a27fa714 /libj2_j2i_add_j2i.3 | |
| parent | libj2_j2i_divmod_j2i_to_j2i: test overflow edge case (diff) | |
| download | libj2-ac0dd6c546feaec1dec667f01616a2db709bedaf.tar.gz libj2-ac0dd6c546feaec1dec667f01616a2db709bedaf.tar.bz2 libj2-ac0dd6c546feaec1dec667f01616a2db709bedaf.tar.xz | |
Add subtraction and addition with carry/borrow and add abs_diff1.2
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'libj2_j2i_add_j2i.3')
| -rw-r--r-- | libj2_j2i_add_j2i.3 | 37 |
1 files changed, 37 insertions, 0 deletions
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), |
