-
Notifications
You must be signed in to change notification settings - Fork 3
ArithmeticParser
Back to home | Back to Reference | View raw text
Contains functionality to parse and evaluate math arithmetic expressions.
flowchart LR
classDef interfaceStyle stroke-dasharray: 5 5;
classDef abstractStyle stroke-width:4px
subgraph SolidShineUi
SolidShineUi.ArithmeticParser[[ArithmeticParser]]
end
Returns | Name |
---|---|
double |
Evaluate (string input)Evaluate an arithmetic expression and output the result (i.e. "2+5" will output "7"). See remarks for more info on supported functions. |
bool |
IsValidString (string input)Check if a string can be parsed as an expression. |
Contains functionality to parse and evaluate math arithmetic expressions.
public static double Evaluate(string input)
Type | Name | Description |
---|---|---|
string |
input | The arithmetic expression to evaluate. |
Evaluate an arithmetic expression and output the result (i.e. "2+5" will output "7"). See remarks for more info on supported functions.
Supports addition, subtraction, multiplication, division, and exponents. Also supports parantheses (with implied multiplcation) and negative numbers.
Uses order of operations: exponents, division, multiplication, subtraction, addition.
Whitespace and new-line characters are removed prior to evaluation, and the literal characters ×, ⋅, and ÷ are replaced with their representations *, *, and /.
The result of the expression.
Name | Description |
---|---|
FormatException | Thrown if the expression is not valid (contains unrecognized characters or a mismatched number of parantheses). |
public static bool IsValidString(string input)
Type | Name | Description |
---|---|---|
string |
input | The string to parse. |
Check if a string can be parsed as an expression.
True if it is a string that can be parsed. False if it contains invalid characters.
Generated with ModularDoc