Skip to content

Commit

Permalink
chore(core): add custom power of 2 support for u128
Browse files Browse the repository at this point in the history
  • Loading branch information
IceTDrinker committed Feb 26, 2024
1 parent 8046849 commit d770a27
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tfhe/src/core_crypto/commons/numeric/unsigned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,10 @@ macro_rules! implement {
.wrapping_rem(custom_modulus_u128)
.cast_into()
} else {
todo!("wrapping_add_custom_mod is not yet implemented for types wider than u64")
if custom_modulus.is_power_of_two() {
return self.wrapping_add(other).wrapping_rem(custom_modulus);
}
todo!("wrapping_add_custom_mod is not yet implemented for non power of two moduli wider than u64")
}
}
#[inline]
Expand All @@ -172,7 +175,10 @@ macro_rules! implement {
.wrapping_rem(custom_modulus_u128)
.cast_into()
} else {
todo!("wrapping_sub_custom_mod is not yet implemented for types wider than u64")
if custom_modulus.is_power_of_two() {
return self.wrapping_sub(other).wrapping_rem(custom_modulus);
}
todo!("wrapping_sub_custom_mod is not yet implemented for non power of two moduli wider than u64")
}
}
#[inline]
Expand Down

0 comments on commit d770a27

Please sign in to comment.