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

Decimal checked multiplication and exponentiation #1239

Merged
merged 5 commits into from
Mar 10, 2022
Merged

Conversation

uint
Copy link
Contributor

@uint uint commented Mar 10, 2022

Long time no PR! Bringing some math with me here.

Copy link
Member

@webmaster128 webmaster128 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful. Great test coverage, thanks!

(Decimal::permille(6), Decimal::permille(13)),
];

// The regular std::ops::Mul is our source of truth for these tests.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

assert_eq!(Decimal::one().checked_pow(exp).unwrap(), Decimal::one());
}

// Do we leave 0^0 undefined?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about going with the Rust standard library behaviour of expecting 1 in the implementation, even though this is mathematically undefined.

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=20df6716048e77087acd40194b233494

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense! Done.

@webmaster128 webmaster128 mentioned this pull request Mar 10, 2022
11 tasks
@webmaster128
Copy link
Member

Added this to #1186. If you're in the mood to finish the checked_pow row, I'd appreciate that.

Co-authored-by: Simon Warta <2603011+webmaster128@users.noreply.github.com>
@uint
Copy link
Contributor Author

uint commented Mar 10, 2022

Added this to #1186. If you're in the mood to finish the checked_pow row, I'd appreciate that.

Not today, but I'll take a look between other work. Nice to change things up a bit.

@webmaster128 webmaster128 merged commit edb05f4 into main Mar 10, 2022
@webmaster128 webmaster128 deleted the decimal-pow branch March 10, 2022 20:32
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