CodePlea icon
CodePlea
Random thoughts on programming

C Math Evaluation Library: TinyExpr


Summary

Fork me on GitHub

TinyExpr Logo

TinyExpr is a very small parser and evaluation library for evaluating math expressions from C. It's open-source, free, and self-contained in a single C code file and header file. TinyExpr is extremely easy to use.

Code Sample

#include "tinyexpr.h"
#include <stdio.h>

int main(int argc, char *argv[])
{
    const char *expression = "sqrt(3^2+4^2)";
    printf("Result: %f\n", te_interp(expression, 0));
    return 0;
}

Features

  • ANSI C with no dependencies.
  • Contained in a single source code and header file.
  • Simple, fast, thread-safe, easily extendible.
  • Implements standard operator precedence and standard math functions.
  • Includes examples and test suite.
  • Released under the zlib license - free for nearly any use.

Links