PhilippHochmann / Ccalc
Licence: gpl-3.0
Scientific calculator in which you can define new constants and functions
Stars: ✭ 19
Programming Languages
c
50402 projects - #5 most used programming language
Projects that are alternatives of or similar to Ccalc
Sharpmath
A small .NET math library.
Stars: ✭ 36 (+89.47%)
Mutual labels: parser, function, calculator, expression
String Calc
PHP calculator library for mathematical terms (expressions) passed as strings
Stars: ✭ 60 (+215.79%)
Mutual labels: parser, calculator
rclc
Mathematical expression calculator with big integers, floats, common fractions, and complex numbers support
Stars: ✭ 24 (+26.32%)
Mutual labels: calculator, expression
Metric Parser
📜 AST-based advanced mathematical parser written by Typescript.
Stars: ✭ 26 (+36.84%)
Mutual labels: parser, expression
Formula Parser
Parsing and evaluating mathematical formulas given as strings.
Stars: ✭ 62 (+226.32%)
Mutual labels: parser, expression
Pegparser
💡 Build your own programming language! A C++17 PEG parser generator supporting parser combination, memoization, left-recursion and context-dependent grammars.
Stars: ✭ 164 (+763.16%)
Mutual labels: parser, calculator
Expressionevaluator
A Simple Math and Pseudo C# Expression Evaluator in One C# File. Can also execute small C# like scripts
Stars: ✭ 194 (+921.05%)
Mutual labels: parser, expression
Insect
High precision scientific calculator with support for physical units
Stars: ✭ 2,469 (+12894.74%)
Mutual labels: parser, calculator
Algebraicengine Fraction
a calculating engine~
Stars: ✭ 311 (+1536.84%)
Mutual labels: parser, calculator
Dasel
Query, update and convert data structures from the command line. Comparable to jq/yq but supports JSON, TOML, YAML, XML and CSV with zero runtime dependencies.
Stars: ✭ 759 (+3894.74%)
Mutual labels: parser
Esprima
ECMAScript parsing infrastructure for multipurpose analysis
Stars: ✭ 6,391 (+33536.84%)
Mutual labels: parser
Node Csv Parse
CSV parsing implementing the Node.js `stream.Transform` API
Stars: ✭ 768 (+3942.11%)
Mutual labels: parser
Netlist Graph
Java library for parsing and manipulating graph representations of gate-level Verilog netlists
Stars: ✭ 7 (-63.16%)
Mutual labels: parser
Bytecode
Fast, lightweight Java bytecode parsing and manipulation library.
Stars: ✭ 17 (-10.53%)
Mutual labels: parser
Expr Eval
Mathematical expression evaluator in JavaScript
Stars: ✭ 752 (+3857.89%)
Mutual labels: parser
Vault Operator
Run and manage Vault on Kubernetes simply and securely
Stars: ✭ 750 (+3847.37%)
Mutual labels: operator
Fuzi
A fast & lightweight XML & HTML parser in Swift with XPath & CSS support
Stars: ✭ 894 (+4605.26%)
Mutual labels: parser
ccalc
Scientific calculator in which you can define new functions and constants
Setup guide
Arch and Manjaro
You can install package ccalc
directly from the AUR.
Install from GitHub
- Clone repository.
- If you want to use readline, download its development files (Ubuntu:
sudo apt-get install libreadline-dev
). If you do not want to use it, change the first line ofmake.sh
touse_readline=false
. - In root of repository, run
./make.sh [-t]
to compile sources and optionally run tests.
How to use it
When starting the calculator normally, you can enter expressions and commands interactively. Passed arguments will be evaluated beforehand. You can pipe in contents which will be evaluated as if typed in, after that the calculator terminates and does not enter interactive mode.
Syntax
- Just type in a mathematical expression to evaluate it.
- Use
ans
or@<index>
to reference previous results. - Two subexpressions next to each other without an infix operator will be multiplied (e.g.
2a
or(x-1)(y+1)
). - You can define functions (and even overload them by arity) and constants (e.g.
myFunc(x) = x^2
,myConst = 42
). - When applying unary functions to a literal, you can omit parentheses (e.g.
sin2
). - Any line starting with
'
will be ignored (useful for comments in files to be loaded). - Use
$
to parse the following expression with maximal precedence, like in Haskell.
Available commands
Command | Description |
---|---|
<func|const> = <after> |
Adds or redefines function or constant. |
table <expr> ; <from> ; <to> ; <step> [fold <expr> ; <init>] |
Prints table of values and optionally folds them. In fold expression, x is replaced with the intermediate result (init in first step), y is replaced with the current value. Result of fold is stored in history. |
load <path> |
Loads file as if its content had been typed in. |
debug <expr> |
Visually prints abstract syntax tree of expression. |
help [operators] |
Lists available commands and operators. |
clear [last] |
Clears all or last user-defined functions and constants. |
quit |
Closes application. |
Infix operators
Name | Associativity | Precedence | Description |
---|---|---|---|
+ |
Both | 2 | Addition |
- |
Left | 2 | Subtraction |
* |
Both | 3 | Multiplication |
/ |
Left | 3 | Division |
^ |
Right | 4 | Exponentiation |
C |
Left | 1 | Binomial coefficient |
mod |
Left | 1 | Modulo operator |
Prefix operators
Name | Precedence | Description |
---|---|---|
+ |
6 | Identity |
- |
6 | Negation |
Postfix operators
Name | Precedence | Description |
---|---|---|
! |
5 | Factorial |
% |
5 | Division by 100 |
Functions
Name | Description |
---|---|
exp(x) |
Natural exponential function |
root(x, n) |
nth root of x |
sqrt(x) |
Square root |
log(x, n) |
Logarithm to base n |
ln(x) |
Natural logarithm |
ld(x) |
Binary logarithm |
lg(x) |
Logarithm to base 10 |
sin(x) |
Sine |
cos(x) |
Cosine |
tan(x) |
Tangent |
asin(x) |
Inverse sine |
acos(x) |
Inverse cosine |
atan(x) |
Inverse tangens |
sinh(x) |
Hyperbolic sine |
cosh(x) |
Hyperbolic cosine |
tanh(x) |
Hyperbolic tangent |
asinh(x) |
Inverse hyperbolic sine |
acosh(x) |
Inverse hyperbolic cosine |
atanh(x) |
Inverse hyperbolic tangent |
max(*) |
Maximum |
min(*) |
Minimum |
abs(x) |
Absolute value |
ceil(x) |
Round up to nearest integer |
floor(x) |
Round down to nearest integer |
round(x) |
Round to nearest integer |
trunc(x) |
Round towards 0 to nearest integer |
frac(x) |
Fractional part of x |
sgn(x) |
Sign of x (-1, 0, 1) |
sum(*) |
Sum of all operands |
prod(*) |
Product of all operands |
avg(*) |
Arithmetic mean of all operands |
gcd(x, y) |
Greatest common divisor |
lcm(x, y) |
Least common multiple |
rand(min, max) |
Random integer between min and max (exclusive) |
fib(n) |
Fibonacci sequence |
gamma(x) |
Gamma function |
Note:
-
*
is used to denote arbitrary number of operands - Where operands are expected to be integer-valued, they will be truncated
- A function will return
NaN
on otherwise malformed arguments
Constants
Name | Value | Description |
---|---|---|
pi |
3.14159265359 | Archimedes' constant |
e |
2.71828182846 | Euler's number |
phi |
1.61803398874 | Golden ratio |
clight |
299792458 | Speed of light [m/s] |
csound |
343.2 | Speed of sound in air at 20 °C [m/s] |
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].