marcellperger1 / mathexprcalculatorjava Goto Github PK
View Code? Open in Web Editor NEWA basic calculator to evaluate math expressions in text
License: MIT License
A basic calculator to evaluate math expressions in text
License: MIT License
Add support for -
as a prefix operator (e.g. -(1+2)
). There is currently support for it but only as a part of a literal.
So currently this is allowed:
-1 + 2
2--1
4*-2*(-1/-2)
And this is not:
-(1+1)
--2*2
And this is interpreted incorrectly:
-1**2 # Gives 1.0 ((-1)**2), should give -1.0 (-(1**2))
So we need to:
-
(**
< precedence < */
)2**-1
and 2**-3**-2
. Python does this using:
prefixop = '-' power | '+' power | ...
power = primary '**' prefixop
primary = ... | '(' ... ')' | ...
Upload coverage output to github pages to make it easier to view where the missed lines are.
The output directory for JaCoCo coverage is target/site/jacoco
.
Potential problems:
Add a CLI something like this:
$ mathexpr '2. + 2.3 * 1.8 ** 2 / .9'
20.28
with extra options like rounding (-R
?), interactive (-i
)
Add the MIT license
Add an interactive mode/shell like this:
>? 2. + 2.3 * 1.8 ** 2 / .9
10.28
Maybe round the result to 12 sf to avoid FP issues.
We need to figure out how to do the exception handling nicely and consistently.
Originally posted by @MarcellPerger1 in #2 (comment)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.