diff --git a/src/evaluate/operator.rs b/src/evaluate/operator.rs index bc77de4..1268554 100644 --- a/src/evaluate/operator.rs +++ b/src/evaluate/operator.rs @@ -162,6 +162,11 @@ pub fn eval_operator(context: &mut Context, g: &Expression) -> Result for FloatBase { (!modulus.fract().unwrap().is_zero()) } { panic!() } - FloatBase{val : self.val.fract() % modulus.val.fract()} + FloatBase{val : self.val.trunc() % modulus.val.trunc()} } } diff --git a/src/quantity/scalar/scalar.rs b/src/quantity/scalar/scalar.rs index 514e575..756e5bb 100644 --- a/src/quantity/scalar/scalar.rs +++ b/src/quantity/scalar/scalar.rs @@ -186,7 +186,7 @@ impl Scalar { pub fn is_nan(&self) -> bool { match self { Scalar::Float {v} => {v.val.is_nan()}, - Scalar::Rational {..} => {panic!()} + Scalar::Rational {..} => {false} } } diff --git a/src/tests.rs b/src/tests.rs index 0f41c8d..cf30e25 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -162,6 +162,7 @@ fn operators() { good_expr("2", "6/3"); good_expr("2", "5%3"); + good_expr("4", "2^5 mod 7"); good_expr("8", "5+3"); good_expr("64", "4^3"); good_expr("64", "4 ^ 3");