shaiq-dev / eval

A fast math expression evaluator written in C

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fast and efficient math expression evaluator in C

A simple eval() that can parse and evaluate mathematical expressions really fast.

Usage

#include <eval.h>

int
main(int argc, char *argv[])
{
    double ans;
    
    // Expressions
    ans = eval("1+1*4");                // 5
    ans = eval("10+1*0");               // 10

    // Expressions with Parentheses
    ans = eval("1+1(5*2)");             // 11
    ans = eval("3+(5*2)");              // 13

    // Erros
    ans = eval("2/0");                  // eval: division by zero
    
    ans = eval("1+2/(3 * a)")
    //  "1+2/(3 * a)"
    //            ^
    // eval: unsupported operand           
}

About

A fast math expression evaluator written in C

License:MIT License


Languages

Language:C 97.4%Language:Makefile 2.6%