calc_lib
A crate for evaluating algebraic expressions from input using correct order of operations.
This was designed originally for use in terminal based calculator apps.
Features
- Basic algebraic operations
- Proper order of operations (functions are always evaluated first, then PEMDAS)
- Optional defined variables
- Integer operations and floating point operations (either/or)
- Functions such as log, sin, cos, tan, etc.
- Optional defined functions
Planned Features
- equation validation (such as
2 + 2 = 4
which is valid, and2 + 2 = 5
which is not) - solving for a variable (such as
x + 2 = 4
will result inx = 2
)
Features that may be implemented in the future
- solving for multiple variables (such as
3x - y = 7
,2x + y = 8
will result inx = 3
,y = 2
)
Default functions
accessed with Functions::default();
log(base, value)
sqrt(value)
sin(value)
cos(value)
tan(value)
Custom Error system:
- Exposes the Error enum which allows the user to determine what type of error occurred, and have all the relevant information about it
- Allows for the user to handle errors in their own way if needed, but they can also just be printed out.
Examples:
Integer equations:
// evaluates an algebraic equation
use evaluate;
Decimal Equations:
use evaluate;
Solving with variables:
use ;