https://github.com/liulietlee/llcalculatorbrain
Calculate string formula
https://github.com/liulietlee/llcalculatorbrain
Last synced: 3 months ago
JSON representation
Calculate string formula
- Host: GitHub
- URL: https://github.com/liulietlee/llcalculatorbrain
- Owner: LiulietLee
- License: mit
- Created: 2016-01-16T14:00:25.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-11-19T07:48:21.000Z (over 7 years ago)
- Last Synced: 2025-01-20T08:28:25.095Z (5 months ago)
- Language: Swift
- Homepage:
- Size: 210 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# LLCalculatorBrain
This is a model that is used to figure out string formula.## Installation
Just move LLCalculatorBrain.swift to your project.## Usage
You can see an example in /SampleExample
```swift
let calculatorBrain = LLCalculatorBrain()let equation = "tan(2*3^(3+2-3.123)/12.2)+sin(pi)+cos(2)*sqrt(144)" // Or something like this
let result = calculatorBrain.calculateThisEquation(equation) // result = -1.54053662
```
There MUST BE a "(" behind sin, cos, tan and sqrt.### Error Code
* Error 1: Divide by zero
* Error 2: Parentheses do not match
* Error 3: Negative under sqrt
* Error 4: Wrong Equation
* Error 5: Empty Equation## TO DO
* More Error Catch