3 ms·
I may be late to answer here, but no you couldn't reasonably make int a bignum in C. Unsigned integers are defined to wrap around, so certainly not there. Sign
by TorKlingberg 10y ago
I may be late to answer here, but no you couldn't reasonably make int a bignum in C. Unsigned integers are defined to wrap around, so certainly not there.
Signed overflow is undefined behaviour so the compiler and runtime can do anything. But, where would it store the extra bits? It could call malloc, but it wouldn't know when to free. It would violate the expectation that memory is managed manually in C. Not all C code even uses malloc. Or, what if the int is in a struct? Should the implementation go allocate extra overflow space elsewhere, and then what happens when you memcpy the struct?
I think there is a strong impedance mismatch between bignums and languages that aren't garbage collected.