Merge pull request #1 from ethwu/master

Correct typo in lexer
This commit is contained in:
Kasper 2020-10-12 20:13:33 +02:00 committed by GitHub
commit bb4bdb72f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -163,7 +163,7 @@ pub fn lex(input: &str, allow_trailing_operators: bool, default_degree: Unit) ->
"day" | "days" => tokens.push(Token::Unit(Day)),
"wk" | "wks" | "week" | "weeks" => tokens.push(Token::Unit(Week)),
"mo" | "mos" | "month" | "months" => tokens.push(Token::Unit(Month)),
"q" | "quater" | "quaters" => tokens.push(Token::Unit(Month)),
"q" | "quarter" | "quarters" => tokens.push(Token::Unit(Quarter)),
"yr" | "yrs" | "year" | "years" => tokens.push(Token::Unit(Year)),
"decade" | "decades" => tokens.push(Token::Unit(Decade)),
"century" | "centuries" => tokens.push(Token::Unit(Century)),

View File

@ -422,7 +422,7 @@ pub fn divide(left: Number, right: Number) -> Result<Number, String> {
} else if lcat == rcat {
// 1 km / 1 km
let (left, right) = convert_to_lowest(left, right)?;
Ok(Number::new(left.value * right.value, NoUnit))
Ok(Number::new(left.value / right.value, NoUnit))
} else if (lcat == Area && rcat == Length) || (lcat == Volume && rcat == Area) {
// 1 km2 / 1 km, 1 km3 / 1 km2
let result = (left.value * left.unit.weight()) / (right.value * right.unit.weight());