Skip to content

Commit

Permalink
Make parser treat all exponent literals as float
Browse files Browse the repository at this point in the history
  • Loading branch information
Haydoggo committed Feb 5, 2022
1 parent 29c4644 commit 1305ff9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
4 changes: 1 addition & 3 deletions core/math/expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ Error Expression::_get_token(Token &r_token) {
is_float = true;
} else if (c == 'e') {
reading = READING_EXP;
is_float = true;
} else {
reading = READING_DONE;
}
Expand Down Expand Up @@ -409,9 +410,6 @@ Error Expression::_get_token(Token &r_token) {
exp_beg = true;

} else if ((c == '-' || c == '+') && !exp_sign && !exp_beg) {
if (c == '-') {
is_float = true;
}
exp_sign = true;

} else {
Expand Down
2 changes: 1 addition & 1 deletion tests/core/math/test_expression.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ TEST_CASE("[Expression] Scientific notation") {
expression.parse("2e5") == OK,
"The expression should parse successfully.");
CHECK_MESSAGE(
Math::is_equal_approx(double(expression.execute()), 25),
Math::is_equal_approx(double(expression.execute()), 2e5),
"The expression should return the expected result.");

CHECK_MESSAGE(
Expand Down

0 comments on commit 1305ff9

Please sign in to comment.