https://github.com/cpiber/evalmath
Math string evaluation
https://github.com/cpiber/evalmath
Last synced: 10 months ago
JSON representation
Math string evaluation
- Host: GitHub
- URL: https://github.com/cpiber/evalmath
- Owner: cpiber
- Created: 2020-09-25T16:23:42.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-05-16T15:52:50.000Z (about 2 years ago)
- Last Synced: 2025-03-05T10:18:01.997Z (over 1 year ago)
- Language: C++
- Homepage:
- Size: 223 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# EvalMath
Math string evaluation.
Repo includes implementations in various languages (java and counting).
Created for learning purposes.
## Usage
Pass a mathematical expression as argument(s). All arguments are concatenated into one string.
If no arguments are passed, interactive mode is started. Enter your equations when prompted. Exit by passing an empty string or pressing CTRL+C.
In the first mode of operation, errors are hidden, and only null is printed. In the second mode of operation more information is printed.
Note that EvalMath supports `()`, `[]` and `{}` for brackets but does not check that the matching bracket is the same type. I.e. `(expr]` is just as valid as `(expr)`.
### Supported operations
- `-` subtraction / negation
- `+` addition
- `*` multiplication
- `/` division
- `%` modulo
- `\` integer division
- `^` exponentiation
### Language specific notes
#### Java
EvalMath does not explicitly check for division by zero. By language design this returns `Infinity` except when using integer division `\`, in which case an error is returned. Modulo `%` returns `NaN`.
## Building JVM-based implementations
Build all languages: `./gradlew build` or `gradlew.bat build` (windows)
Building specific language: `./gradlew ::build` where `` is the language folder (currently `java`).
Running specific language: `./gradlew ::run --console=plain`. To pass arguments, add `--args ""`.
For more information visit [the docs](https://docs.gradle.org/current/userguide/userguide.html)