kokke / tiny-bignum-c

Small portable multiple-precision unsigned integer arithmetic in C
The Unlicense
424 stars 85 forks source link

performance vs GMP? negative number support? #18

Closed timotheecour closed 3 years ago

timotheecour commented 4 years ago

are there any links to performance comparisons against GMP?

is there any planned work to support negative integers?

links

see also https://github.com/ilia3101/Big-Integer-C/issues/1

kokke commented 3 years ago

Hi @timotheecour and thanks for your interest in this project :)

are there any links to performance comparisons against GMP?

I've made no performance comparisons, and know of none others have done. I suspect this library is much slower than GMP in almost all cases. GMP utilizes lots of optimizations and numerical analysis, this library has almost no optimizations and works rather naiively; the emphasis is on simple code and small footprint.

is there any planned work to support negative integers?

No plans for implementing negative numbers, but I don't think it would require much though. Without having thought about it much, I think it's mostly an issue of how you input/output the negative numbers, as the underlying math mostly works out-of-the-box on unsigned representation of a negative number. E.g. -1 represented as MAX (i.e. 0 - 1 becomes MAX because of underflow/wrapping).

See also this issue: https://github.com/kokke/tiny-bignum-c/issues/3

Did that make sense to you? I am having a hard time explaining my thoughts about this in writing at the moment...

kokke commented 3 years ago

Hi again @timotheecour

I will close this issue now, after seeing your thumbs-up emoji :+1: Feel free to reopen if you feel for it :)