Skip to content

Commit

Permalink
Add arithmetic function multiply_by_ten_to_the_uint
Browse files Browse the repository at this point in the history
  • Loading branch information
akubera committed Oct 28, 2024
1 parent 3c58a3e commit 8886fc0
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/arithmetic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,18 @@ pub(crate) fn ten_to_the_uint(pow: u64) -> BigUint {
}
}

pub(crate) fn multiply_by_ten_to_the_uint<T, P>(n: &mut T, pow: P)
where T: MulAssign<u64> + MulAssign<BigUint>,
P: ToPrimitive
{
let pow = pow.to_u64().expect("exponent overflow error");
if pow < 20 {
*n *= 10u64.pow(pow as u32);
} else {
*n *= ten_to_the_uint(pow);
}

}

/// Return number of decimal digits in integer
pub(crate) fn count_decimal_digits(int: &BigInt) -> u64 {
Expand Down

0 comments on commit 8886fc0

Please sign in to comment.