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

Use modulus operator #3

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

Use modulus operator #3

wants to merge 2 commits into from

Conversation

itmilos
Copy link

@itmilos itmilos commented Mar 6, 2024

Code was performing the multiplication (self.numerator as u128) * expected_acurast_amount twice, once for calculating amount and once for checking if there's a remainder. This is inefficient as it involves duplicate calculations.

The refactored code introduces a new variable product to store the result of the multiplication (self.numerator as u128) * expected_acurast_amount. This way, the multiplication is performed only once, and the result is reused in the calculation of amount and in the check for a remainder.

itmilos added 2 commits March 6, 2024 15:40
prevent division operation repetition
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.

1 participant