Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xuchunyang/eval
evaluate algebraic string
https://github.com/xuchunyang/eval
Last synced: about 1 month ago
JSON representation
evaluate algebraic string
- Host: GitHub
- URL: https://github.com/xuchunyang/eval
- Owner: xuchunyang
- Created: 2014-06-05T06:27:44.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-06-07T18:05:26.000Z (over 9 years ago)
- Last Synced: 2024-10-16T01:46:12.594Z (3 months ago)
- Language: C
- Homepage:
- Size: 188 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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