-
Notifications
You must be signed in to change notification settings - Fork 37
Description
@brianharvey mentioned this is high on his wishlist
C23 adds the _BitInt() type macro for arbitrary size ints; supported by clang and GCC 14; BITINT_MAXWIDTH 8388608 on clang. BitInts support all the normal integer operations. Standard library support isn't quite there yet and the ABI is unstable, but those aren't necessarily blockers.
typedef unsigned _BitInt(1024) uint1024_t;
uint1024_t a = eleventyquintillion;Python has a highly optimized arbitrary length integer implementation. It's written in portable C that we could probably adapt to our needs. We would have to keep their GPL-compatible license on whatever files we ganked https://docs.python.org/3/license.html#python-software-foundation-license-version-2
There's also https://gmplib.org/ "GNU MP is a portable library written in C for arbitrary precision arithmetic on integers, rational numbers, and floating-point numbers. It aims to provide the fastest possible arithmetic for all applications that need higher precision than is directly supported by the basic C types."
Or roll our own.