-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Arbitrary-Precision Arithmetic base #1034
Comments
I'm not sure, base conversion is typically quite slow |
I guess it depends which is done more - base conversion or arithmetic. I think GMP uses full words as its "base" to speed up operations. |
@jakobkogler what do you think? |
I personally use the base The obvious algorithm for base conversion is Also, modulo operations are not that bad. For addition/subtraction you don't need to do a modulo operation, you can just compare ala However you are correct, that if you do a lot of operations, then a binary base will be faster. Anyway, big integer problems in competitive programming don't have super tight limits. So it doesn't matter too much which version we present on the website. (Although the D&C trick might be interesting either way, regardless if it leads to a better way or not). If you want to know the difference, why not implement two versions yourself and publish the results? |
Article: Arbitrary-Precision Arithmetic
Problem:
Is using base 10^9 really better than using a base like 2^30? Seems like modulo and carry flag operations would be much more efficient, at the cost of slower decimal I/O.
The text was updated successfully, but these errors were encountered: