aboutsummaryrefslogtreecommitdiffstats
path: root/libj2_j2i_lsh.3
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2026-02-11 11:20:10 +0100
committerMattias Andrée <m@maandree.se>2026-02-11 11:20:10 +0100
commit0d4c3e8f6be098e953502589b17cb28197322442 (patch)
treedf3a13e786769e78d3d6201150f4018dc0c22cb5 /libj2_j2i_lsh.3
parentTest sat_add (diff)
downloadlibj2-0d4c3e8f6be098e953502589b17cb28197322442.tar.gz
libj2-0d4c3e8f6be098e953502589b17cb28197322442.tar.bz2
libj2-0d4c3e8f6be098e953502589b17cb28197322442.tar.xz
Finish signed saturated math
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'libj2_j2i_lsh.3')
-rw-r--r--libj2_j2i_lsh.323
1 files changed, 22 insertions, 1 deletions
diff --git a/libj2_j2i_lsh.3 b/libj2_j2i_lsh.3
index 26c2455..aa89dbd 100644
--- a/libj2_j2i_lsh.3
+++ b/libj2_j2i_lsh.3
@@ -27,6 +27,14 @@ int \fBlibj2_ju_lsh_to_j2u_overflow\fP(uintmax_t \fIa\fP, unsigned \fIb\fP, stru
int \fBlibj2_j2u_lsh_overflow_p\fP(const struct libj2_j2u *\fIa\fP, unsigned \fIb\fP);
int \fBlibj2_ju_lsh_overflow_p\fP(uintmax_t \fIa\fP, unsigned \fIb\fP);
+
+void \fBlibj2_j2i_sat_lsh\fP(struct libj2_j2i *\fIa\fP, unsigned \fIb\fP);
+void \fBlibj2_j2i_sat_lsh_to_j2i\fP(const struct libj2_j2i *\fIa\fP, unsigned \fIb\fP, struct libj2_j2i *\fIr\fP);
+void \fBlibj2_ji_sat_lsh_to_j2i\fP(intmax_t \fIa\fP, unsigned \fIb\fP, struct libj2_j2i *\fIr\fP);
+
+void \fBlibj2_j2u_sat_lsh\fP(struct libj2_j2u *\fIa\fP, unsigned \fIb\fP);
+void \fBlibj2_j2u_sat_lsh_to_j2u\fP(const struct libj2_j2u *\fIa\fP, unsigned \fIb\fP, struct libj2_j2u *\fIr\fP);
+void \fBlibj2_ju_sat_lsh_to_j2u\fP(uintmax_t \fIa\fP, unsigned \fIb\fP, struct libj2_j2u *\fIr\fP);
.fi
.PP
Link with
@@ -83,6 +91,13 @@ if any discarded bit (any of the
.I b
most significant bits) was set.
.PP
+The
+.BR sat_lsh -functions
+use saturated arithmetics, meaning that the result
+will be the maximum representable value on positive
+overflow and the minimum representable value on
+negative overflow.
+.PP
The arguments are assumed to be
.RI non- NULL .
@@ -120,8 +135,14 @@ The
.BR libj2_j2i_lsh_to_j2i_overflow (),
.BR libj2_ji_lsh_to_j2i_overflow (),
.BR libj2_j2i_lsh_overflow_p (),
+.BR libj2_ji_lsh_overflow_p (),
+.BR libj2_j2i_sat_lsh (),
+.BR libj2_j2i_sat_lsh_to_j2i (),
+.BR libj2_ji_sat_lsh_to_j2i (),
+.BR libj2_j2u_sat_lsh (),
+.BR libj2_j2u_sat_lsh_to_j2u (),
and
-.BR libj2_ji_lsh_overflow_p ()
+.BR libj2_ju_sat_lsh_to_j2u ()
functions were added in version 1.1 of
.BR libj2 .