#expression-evaluator #numbers #basic #operator #negative #sin #tan

bt_math

Basic math expression evaluator library. Support basic math operators (+,-,*,/,^), parenthesis, and functions such as log10, ln, log2, exp, sin, cos, tan, asin, acos, atan, abs, sqrt. Support PI and E (Euler's number) as constants. Support negative numbers/expressions. Pow(x,y) supported

4 releases (2 breaking)

new 0.3.0 Feb 16, 2025
0.2.1 Jan 17, 2025
0.2.0 Jan 17, 2025
0.1.0 Nov 19, 2024

#428 in Math

Download history 144/week @ 2024-11-19 7/week @ 2024-11-26 1/week @ 2024-12-03 6/week @ 2024-12-10 2/week @ 2024-12-17 205/week @ 2025-01-14 21/week @ 2025-01-21 4/week @ 2025-01-28 30/week @ 2025-02-04 90/week @ 2025-02-11

166 downloads per month

GPL-3.0-only

16KB
230 lines

Project Title

BT MATH

Description

A simple implementation of an expression evaluator that can handle basic arithmetic operations, parentheses, and some mathematical functions that provide a way to evaluate mathematical expressions using RPN (Reverse Polish Notation) implemented in two parts: parsing and evaluation.

Support the use of PI and E (Euler's number), negative numbers or expressions, and the following functions: ln, log2, exp (e^#), asin, acos, atan, sin, cos. tan. abs, sqrt. log10

Usage

let expression = "2 + 3 * 4";
 .......
let f = evaluate_expression(expression).unwrap();

Version History

  • 0.1.0
    • Initial Release
  • 0.2.0
    • Added PI and E (Euler's number) support. Support for negative numbers. Fix error with log (log was removed) and added log10.
  • 0.3.0
    • POW(x,y) is a function now supported. Also fix some negative number issues. Make it case insensitive.

License

GPL-3.0-only

Dependencies

~2.2–3MB
~54K SLoC