Skip to content
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

Modified multiplication function. Base INT_MAX now works for multipli… #40

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

kishanshukla-2307
Copy link

@kishanshukla-2307 kishanshukla-2307 commented Mar 2, 2020

…cation.
a *= 2 here 'a' would overflow if we change the base to INT_MAX. overflow can't occur when a < INT_MAX/2, therefore, the code was working only for base < INT_MAX/2. but now I have changed a *= 2 to a = (a+a)%base which is working for base INT_MAX. (only for multiplication)

@sdkrystian
Copy link

sdkrystian commented Mar 7, 2020

Make sure to guard those calls to min and max.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants