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_sub_ju_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_sub_ju_to_j2u.c')
| -rw-r--r-- | libj2_ju_sub_ju_to_j2u.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/libj2_ju_sub_ju_to_j2u.c b/libj2_ju_sub_ju_to_j2u.c index 5de5046..cedc6f3 100644 --- a/libj2_ju_sub_ju_to_j2u.c +++ b/libj2_ju_sub_ju_to_j2u.c @@ -37,6 +37,10 @@ check(uintmax_t a, uintmax_t b) EXPECT(libj2_ju_sub_ju_to_j2u_overflow(a, b, &r) == expected_overflow); EXPECT(libj2_j2u_eq_j2u(&r, &expected)); + r = (struct libj2_j2u){111, 222}; + libj2_ju_sat_sub_ju_to_j2u(a, b, &r); + EXPECT(expected_overflow ? libj2_j2u_is_zero(&r) : libj2_j2u_eq_j2u(&r, &expected)); + EXPECT(libj2_ju_sub_ju_overflow_p(a, b) == expected_overflow); } |
