Skip to content

Commit

Permalink
re-order boolean conditions
Browse files Browse the repository at this point in the history
Co-authored-by: Ivan Tham <pickfire@riseup.net>
  • Loading branch information
saguywalker and pickfire committed Oct 24, 2022
1 parent d51d596 commit f35b13b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/lex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl Operator {
pub fn operate(self, x: f64, y: f64) -> Result<f64, CalcError> {
if self.token == '/' && y == 0. {
return Err(CalcError::Math(Math::DivideByZero));
} else if self.token == '!' && (x.fract() != 0.0 || x < 0.0) {
} else if self.token == '!' && (x < 0.0 || x.fract() != 0.0) {
return Err(CalcError::Math(Math::OutOfBounds));
} else if self.token == '!' && x == 0.0 {
// Must return 1 manually as 0..=n where n is 0.0 doesn't work AFAIK.
Expand Down

0 comments on commit f35b13b

Please sign in to comment.