Skip to content

Commit

Permalink
Merge pull request #15 from invariant-labs/U320
Browse files Browse the repository at this point in the history
added-u320-type
  • Loading branch information
Sniezka1927 authored Sep 25, 2023
2 parents b514bfe + fe64235 commit debd5ab
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/uint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,27 @@

use uint::construct_uint;

construct_uint! {
pub struct U320(5);
}
construct_uint! {
pub struct U256(4);
}
construct_uint! {
pub struct U192(3);
}


#[allow(dead_code)]
pub const fn to_u256(n: u128) -> U256 {
U256([n as u64, (n >> 64) as u64, 0, 0])
}

// #[allow(dead_code)]
// pub const fn to_u320(n: U256) -> U320 {
// U320([n as u64, (n >> 64) as u64,0,0])
// }

#[cfg(test)]
mod tests {
use super::*;
Expand Down Expand Up @@ -68,4 +77,13 @@ mod tests {
assert_eq!(from, back);
}
}

#[test]
fn test_u320_methods() {
let _max = U320::MAX;
let _from = U320::from(10);
let zero = U320::zero();
let is_zero =zero.is_zero();
assert!(is_zero);
}
}

0 comments on commit debd5ab

Please sign in to comment.