From 0d4c3e8f6be098e953502589b17cb28197322442 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 11 Feb 2026 11:20:10 +0100 Subject: Finish signed saturated math MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libj2_j2i_lsh.3 | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'libj2_j2i_lsh.3') 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 . -- cgit v1.2.3-70-g09d2