Crates.io | calculator-parser |
lib.rs | calculator-parser |
version | 1.0.1 |
source | src |
created_at | 2021-06-12 02:00:05.556511 |
updated_at | 2021-06-21 22:42:54.753024 |
description | A simple calculation parser for user input |
homepage | https://github.com/AsyncBanana/calculator-rs/tree/master/calculator |
repository | |
max_upload_size | |
id | 409186 |
size | 11,349 |
A lightweight rust calculation parser. Only supports basic syntax, eg. no parentheses or functions beyond basic operators.
The current operators that are supported are
Character used | Function |
---|---|
+ |
Add to number |
- |
Subtract from number |
* |
Multiply number |
\ |
Divide number |
^ |
Use an exponent |
Example: 2^2+5
would be transformed into 9. It is pretty much just normal math syntax.
Just pass a string reference to the calculate
function, and a 64 bit floating point number will be returned.