Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/xuchunyang/eval

evaluate algebraic string
https://github.com/xuchunyang/eval

Last synced: about 1 month ago
JSON representation

evaluate algebraic string

Awesome Lists containing this project

README

        

## Evaluate infix expression with C

### Usage
For example, to evaluate "9+(3-1)*3+1.5/0.5":

```c
#include "eval-suffix-expr.h"

char expr[] = "9+(3-1)*3+1.5/0.5";
CAL_ERROR cal_error = {.code = 0, .message = ""};
double rtv = 0.0;

rtv = eval_suffix_expr(expr, &cal_error);
if (cal_error.code != 0) /* Error occurs! */
{
fprintf (stderr, "%s", cal_error.message);
}
else
{
printf ("The result of %s is %f\n", expr, rtv);
}
```

### TODO
- [x] handle exceptions like divison by zero
- [-] clean unnecessary functions