# javacalc **Repository Path**: freeonsky/javacalc ## Basic Information - **Project Name**: javacalc - **Description**: No description available - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-07-26 - **Last Updated**: 2024-07-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # JavaCalc - an algebraic expression calculator **JavaCalc** is a *recursive descent parser* which evaluates math expressions, including a bunch of math functions and with *variables* support. ## Type system **JavaCalc** uses `java.math.BigDecimal` as main type, in order not to lose precision during calculation. ## Usage examples ### Plain math operation BigDecimal result = Calc.eval("(2 + 2) * 3 /2"); ### Using math functions BigDecimal result = Calc.eval("sqrt(9)*sin(3/2)"); ### Using variables Map vars = new HashMap<>(); vars.put("x", 9); vars.put("y", 12.5); BigDecimal result = Calc.eval("x + y*2", vars); ## Available math functions - `sqrt(x)`: square root of `x` - `sin(x)`: sine of `x` radiants - `cos(x)`: cosine of `x` radiants - `tan(x)`: tangent of `x` radiants - `asin(x)`: arcsine of `x` - `acos(x)`: arccosine of `x` - `atan(x)`: arctangent of `x` - `sgn(x)`: signum of `x` (positive: 1, negative: -1, otherwise 0) - `abs(x)`: absolute value of `x`