diff options
| author | Mattias Andrée <m@maandree.se> | 2025-12-06 16:13:53 +0100 |
|---|---|---|
| committer | Mattias Andrée <m@maandree.se> | 2025-12-06 16:13:53 +0100 |
| commit | bc03a666203de25faf6246847fecbc8502267212 (patch) | |
| tree | 080080b24980640c6d4935a4684bf78b4d2d3077 /libj2_ju_lsh_to_j2u.c | |
| parent | Add division with underflow detection (diff) | |
| download | libj2-bc03a666203de25faf6246847fecbc8502267212.tar.gz libj2-bc03a666203de25faf6246847fecbc8502267212.tar.bz2 libj2-bc03a666203de25faf6246847fecbc8502267212.tar.xz | |
Add saturated arithmetic operations
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'libj2_ju_lsh_to_j2u.c')
| -rw-r--r-- | libj2_ju_lsh_to_j2u.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/libj2_ju_lsh_to_j2u.c b/libj2_ju_lsh_to_j2u.c index ca05fbf..d2495e1 100644 --- a/libj2_ju_lsh_to_j2u.c +++ b/libj2_ju_lsh_to_j2u.c @@ -143,6 +143,10 @@ check(const char *pattern) EXPECT(libj2_ju_lsh_to_j2u_overflow(a.low, i, &r) == overflows); EXPECT(libj2_j2u_eq_j2u(&r, &expected)); + r = (struct libj2_j2u){111, 222}; + libj2_ju_sat_lsh_to_j2u(a.low, i, &r); + EXPECT(overflows ? libj2_j2u_is_max(&r) : libj2_j2u_eq_j2u(&r, &expected)); + EXPECT(libj2_ju_lsh_overflow_p(a.low, i) == overflows); } } |
