diff --git a/fixed_wide/src/wide.rs b/fixed_wide/src/wide.rs index 192bead..bf4c96f 100644 --- a/fixed_wide/src/wide.rs +++ b/fixed_wide/src/wide.rs @@ -27,6 +27,16 @@ impl PartialEq for Fixed{ } impl Eq for Fixed{} +impl,Frac> std::ops::Add for Fixed{ + type Output=Self; + fn add(self,rhs:Self)->Self::Output{ + Self{ + bits:self.bits+rhs.bits, + phantom:std::marker::PhantomData, + } + } +} + pub trait WideMul{ type Output; fn wide_mul(self,rhs:Rhs)->Self::Output; diff --git a/src/tests/mod.rs b/src/tests/mod.rs index 478c945..945b406 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -19,6 +19,12 @@ fn wide_int64() { assert_eq!(w3,Planar64Wide3::from((3i128*2).pow(4))); } +#[test] +fn you_can_add_numbers(){ + let a=Planar64Wide3::from((3i128*2).pow(4)); + assert_eq!(a+a,Planar64Wide3::from((3i128*2).pow(4)*2)) +} + #[test] fn wide_vec3(){ let v=Vector3::from_value(Planar64::from(3));