diff options
-rw-r--r-- | src/parserfunc.c | 13 | ||||
-rw-r--r-- | src/test-mp-equation.c | 1 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/parserfunc.c b/src/parserfunc.c index 8f153aa..4ef55d2 100644 --- a/src/parserfunc.c +++ b/src/parserfunc.c @@ -587,7 +587,18 @@ pf_do_x_pow_y_int(ParseNode* self) gint pow; MPNumber* ans = mp_new_ptr(); val = (MPNumber*) (*(self->left->evaluate))(self->left); - pow = super_atoi(self->right->token->string); + + if(!val) + { + val = mp_new_ptr(); + mp_set_from_integer(super_atoi(self->left->token->string), val); + } + + if (self->right->token != NULL) + pow = super_atoi(self->right->token->string); + else + pow = mp_to_integer((MPNumber*) (*(self->right->evaluate))(self->right)); + if(!val) { mp_free(ans); diff --git a/src/test-mp-equation.c b/src/test-mp-equation.c index d31c546..becf742 100644 --- a/src/test-mp-equation.c +++ b/src/test-mp-equation.c @@ -435,6 +435,7 @@ test_equations(void) test("2²", "4", 0); test("2³", "8", 0); test("2¹⁰", "1024", 0); + test("2³ ²", "512", 0); test("(1+2)²", "9", 0); test("(x)²", "4", 0); test("|1−3|²", "4", 0); |