Here is my bigint struct in c++.
https://paste.ubuntu.com/p/Kb2Cwtk6Bg/ (new link is available)
enjoy it :))
upd1 : I added bitwise operator and shift. here is new link.
https://paste.ubuntu.com/p/FdxZ3QMG9h/
upd2 : I added popcount, ctz and tutorial to how to use change base function :D.
you can use the new code below :
https://paste.ubuntu.com/p/ZcMgDhvRhv/
upd3 : I fixed a bug found by WhaleVomit (thanks for noticing). This new code uses more memory. If you wanted to reduce the memory usage, you can use the previous version and you can use .normalize() function on each variable before each operation. It helps a little and the normalize function is of $$$O(n)$$$ where $$$n$$$ is the number of digits of the number you are using normalize on.
you can use the new code below :
https://paste.ubuntu.com/p/dzDJHqp5bf/
https://github.com/AriaAshrafi/BigInt/blob/main/BigInt.cpp
(any suggestion please comment)
Thanks, Very useful. How to use it?
copy and paste it above your code and then use it like int. (like: bigint a;)
What is the maximum we can use for constant Dig?
Don't change Dig. :D I'm still not sure it is okay to change it. I wanted to change base easily with just changing Dig but something went wrong so it's just a constant that is 10. :D (change base is available from base (2 to 10) to base (2 to 10) with function CB(). Exmp: CB(A, 9, 3) will return A in Base(3) (A should be in base 9)).
The way the numbers are stored is highly inefficient if using a small number like 10.
Virtually all functions need to loop over the "digits" of the bignum. So, it would speed up things having a huge base, like 1<<30, or better 1<<62.
That's a good idea. I will fix it one day.
how about using fft in multiplication
I don't know fft yet. :D
Came here to also suggest this
Hi, Can I do documentation on this and share with my friends ? I will mention you as creator and won't change anything in the code ?
Do as you want.
I can't use it.
[Error] 'to_string' was not declared in this scope
it seems that you are using code::blocks unfortunately it's compiler doesn't have to_string() idk why! but in other compilers(like codeforces' ones) this will work fine
I use Code::Blocks and it has std::stoi() and std::to_string(),you need to update version.
yah it seems that they added it finally I didn't use code::block for a while now but I had this problem with it before
Careful with using this template, as there is some bug in the == method that was giving me wrong results (albeit very rarely).
U sure?? Cause == is a very simple function
Yep, I changed
a == b to to_string(a) == to_string(b)
on GCJ today, which made my solution go from WA to AC.
can u give me the problem link??
https://codingcompetitions.withgoogle.com/codejam/round/0000000000435baf/00000000007ae694
My username is WhaleVomit if u want to see my submissions. The test case where == bugs on is
In case you want any other bigint library you can checkout this : bigint c++ (Link to code )
I have been using this for quite some time now, and have not found a bug till date
..
Did you use bots or something to stop others from downvoting you? My friends and I downvoted for many times but it's still 0.
But it's no use. Your contribution still loses xD.
I dont care + Who asked + You are noob