You seem to be missing a few important things here:
- There is a difference between native arithmetic and bignum arithmetic.
- It seems to you that you are interested in arithmetic bignum .
- C ++ does not support bignum arithmetic. Primitive data types are typically native processor arithmetic.
To get bignum arithmetic (arbitrary precision), you need to implement it yourself or use a library. (e.g. GMP ). Unlike Java and C # (among others), C ++ does not have a library for arbitrary precision arithmetic.
All these fantastic algorithms:
- Karatsuba:
O(n^1.585)
- Toom-Cook:
< O(n^1.465)
- FFT:
~ O(n log(n))
applicable only to binum arithmetic, which are implemented in bigmoon libraries. What the processor uses for its own arithmetic operations is somewhat irrelevant, since it is usually a constant time.
In any case, I do not recommend that you try to implement the bignum library. I have done this before, and it is quite demanding (especially math). Therefore, you better use the library.
source share