exp4j Documentation

repository·master·Indexed 19 days ago

https://github.com/fasseg/exp4j

A lightweight mathematical expression evaluator for Java that parses and evaluates string-based expressions involving variables and functions. The library is approximately 50kb and has no external dependencies.

Tokens
221
Snippets
0
Records
2
Agent score
19%

What's inside exp4j

  1. Overview of exp4j

    master
    exp4j is a lightweight mathematical expression evaluator designed for the Java programming language. It is a small library (approximately 50kb) and is notable for having no external dependencies, making it easy to integrate into Java projects.
  2. Handle UnknownFunctionOrVariableException

    master

    When using the Tokenizer, an UnknownFunctionOrVariableException is thrown if the expression contains a function name or variable name that has not been defined or recognized. This exception extends IllegalArgumentException and provides metadata to help locate the error in the input string.

    To debug the error, you can use the following methods on the exception instance:

    • getExpression(): Returns the full expression string that caused the error.
    • getToken(): Returns the specific name of the unknown function or variable.
    • getPosition(): Returns the zero-based starting index of the unknown token within the expression.