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

primitive-types: add U128 full_mul #546

Merged
merged 3 commits into from May 24, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions primitive-types/CHANGELOG.md
Expand Up @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog].
[Keep a Changelog]: http://keepachangelog.com/en/1.0.0/

## [Unreleased]
- Added `U128::full_mul` method. [#546](https://github.com/paritytech/parity-common/pull/546)
### Breaking
- Updated `scale-info` to 0.6. [#519](https://github.com/paritytech/parity-common/pull/519)

## [0.9.0] - 2021-01-27
### Breaking
Expand Down
9 changes: 9 additions & 0 deletions primitive-types/src/lib.rs
Expand Up @@ -125,6 +125,15 @@ mod rlp {

impl_fixed_hash_conversions!(H256, H160);

impl U128 {
/// Multiplies two 128-bit integers to produce full 256-bit integer
/// No overflow possible
ordian marked this conversation as resolved.
Show resolved Hide resolved
#[inline(always)]
pub fn full_mul(self, other: U128) -> U256 {
U256(uint_full_mul_reg!(U128, 2, self, other))
}
}

impl U256 {
/// Multiplies two 256-bit integers to produce full 512-bit integer
/// No overflow possible
ordian marked this conversation as resolved.
Show resolved Hide resolved
Expand Down