mirror of
https://github.com/arnaucube/phantom-zone.git
synced 2026-01-07 22:51:29 +01:00
fix to_i64 for modulus u64
This commit is contained in:
@@ -56,14 +56,14 @@ impl Modulus for u64 {
|
||||
// 0.0?
|
||||
let v = v.round();
|
||||
if v < 0.0 {
|
||||
self - v.to_u64().unwrap()
|
||||
self - v.abs().to_u64().unwrap()
|
||||
} else {
|
||||
v.to_u64().unwrap()
|
||||
}
|
||||
}
|
||||
fn map_element_from_i64(&self, v: i64) -> Self::Element {
|
||||
if v < 0 {
|
||||
self - v.to_u64().unwrap()
|
||||
self - v.abs().to_u64().unwrap()
|
||||
} else {
|
||||
v.to_u64().unwrap()
|
||||
}
|
||||
@@ -171,7 +171,7 @@ impl<T> ModularOpsU64<T> {
|
||||
debug_assert!(a < self.q);
|
||||
debug_assert!(b < self.q);
|
||||
|
||||
if a > b {
|
||||
if a >= b {
|
||||
a - b
|
||||
} else {
|
||||
(self.q + a) - b
|
||||
|
||||
@@ -1927,7 +1927,7 @@ mod tests {
|
||||
let mut bool_evaluator = BoolEvaluator::<
|
||||
Vec<Vec<u64>>,
|
||||
NttBackendU64,
|
||||
WordSizeModulus<CiphertextModulus<u64>>,
|
||||
ModularOpsU64<CiphertextModulus<u64>>,
|
||||
ModularOpsU64<CiphertextModulus<u64>>,
|
||||
>::new(SP_BOOL_PARAMS);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user