aboutsummaryrefslogtreecommitdiffstats
path: root/libquanta_bigint_divmod_small__.c
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2025-12-06 16:24:06 +0100
committerMattias Andrée <m@maandree.se>2025-12-06 16:24:06 +0100
commit5a0ff887b2bdb6d3643b85a7f7042ae20a30e8ab (patch)
tree2c4e3765c62bcd022479a62151b1f0d7278ff773 /libquanta_bigint_divmod_small__.c
parentRefine implementation of Wu's Colour Quantiser (diff)
downloadlibquanta-5a0ff887b2bdb6d3643b85a7f7042ae20a30e8ab.tar.gz
libquanta-5a0ff887b2bdb6d3643b85a7f7042ae20a30e8ab.tar.bz2
libquanta-5a0ff887b2bdb6d3643b85a7f7042ae20a30e8ab.tar.xz
Use libj2 for double-max precision integersHEADmaster
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to '')
-rw-r--r--libquanta_bigint_divmod_small__.c34
1 files changed, 0 insertions, 34 deletions
diff --git a/libquanta_bigint_divmod_small__.c b/libquanta_bigint_divmod_small__.c
deleted file mode 100644
index a2c345f..0000000
--- a/libquanta_bigint_divmod_small__.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/* See LICENSE file for copyright and license details. */
-#include "common.h"
-
-
-uintmax_t
-libquanta_bigint_divmod_small__(struct bigint *big, uintmax_t small)
-{
- uintmax_t q = 0, hi, lo;
- int e = 8 * (int)sizeof(small);
-
-#if 0 /* this would overflow (undefined behaviour) and not fit in the result */
- q = big->high / small;
- q <<= 8 * (int)sizeof(small);
-#endif
- big->high %= small;
-
- while (big->high && --e) {
- hi = small >> (8 * (int)sizeof(small) - e);
- lo = small << e;
-
- if (hi > big->high)
- continue;
- if (hi == big->high && lo > big->low)
- continue;
-
- q |= (uintmax_t)1 << e;
- bigint_sub_small(big, lo);
- big->high -= hi;
- }
-
- q += big->low / small;
- big->low %= small;
- return q;
-}