diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2023-02-01 19:54:33 -0330 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2023-02-01 19:54:33 -0330 |
| commit | 96b768c55caa756e6fc7e7a690211258519683fa (patch) | |
| tree | a3829d0c86be89be028aa4519aa0545a70d15dbd /src/lib.rs | |
| parent | 6e6e7581b4c8575dd379f20a786108ce4edcd9c8 (diff) | |
| download | pfc-96b768c55caa756e6fc7e7a690211258519683fa.zip | |
exponentiation operator
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -31,6 +31,7 @@ impl Calculator { Operator::Sub => self.stack.push(lhs - rhs), Operator::Mul => self.stack.push(lhs * rhs), Operator::Div => self.stack.push(lhs / rhs), + Operator::Exp => self.stack.push(lhs.powf(rhs)), } } } @@ -40,6 +41,7 @@ pub enum Operator { Sub, Mul, Div, + Exp, } impl Operator { @@ -49,6 +51,7 @@ impl Operator { '-' => Ok(Self::Sub), '*' => Ok(Self::Mul), '/' => Ok(Self::Div), + '^' => Ok(Self::Exp), _ => Err(ParseOperatorError(c)), } } |