mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-30 12:10:03 +02:00
[poincare] Parse ".004"
Change-Id: Iea9c7cb82b3f152053193ef5e6fc4c7ee2efc459
This commit is contained in:
@@ -112,8 +112,11 @@ mtxData:
|
||||
|
||||
number:
|
||||
DIGITS { $$ = new Integer($1.address, false); }
|
||||
| DOT DIGITS { $$ = new Complex(nullptr, 0, false, $2.address, $2.length, nullptr, 0, false); }
|
||||
| DIGITS DOT DIGITS { $$ = new Complex($1.address, $1.length, false, $3.address, $3.length, nullptr, 0, false); }
|
||||
| DOT DIGITS EE DIGITS { $$ = new Complex(nullptr, 0, false, $2.address, $2.length, $4.address, $4.length, false); }
|
||||
| DIGITS DOT DIGITS EE DIGITS { $$ = new Complex($1.address, $1.length, false, $3.address, $3.length, $5.address, $5.length, false); }
|
||||
| DOT DIGITS EE MINUS DIGITS { $$ = new Complex(nullptr, 0, false, $2.address, $2.length, $5.address, $5.length, true); }
|
||||
| DIGITS DOT DIGITS EE MINUS DIGITS { $$ = new Complex($1.address, $1.length, false, $3.address, $3.length, $6.address, $6.length, true); }
|
||||
|
||||
exp:
|
||||
|
||||
@@ -24,4 +24,13 @@ QUIZ_CASE(poincare_parser) {
|
||||
a = Expression::parse("-sin(3)*2-3");
|
||||
f = -sinf(3.0f)*2.0f-3.0f;
|
||||
assert(a->approximate(globalContext) == f);
|
||||
|
||||
a = Expression::parse("-.003");
|
||||
f = -0.003f;
|
||||
assert(a->approximate(globalContext) == f);
|
||||
|
||||
char text[10] = {'.', '0', '2', 'E', '2', 0};
|
||||
a = Expression::parse(text);
|
||||
f = 2.0f;
|
||||
assert(a->approximate(globalContext) == f);
|
||||
}
|
||||
Reference in New Issue
Block a user