Rpnc is a simple RPN calculator where everything is passed from the command line. There isn't any interactive mode. It is coded in C and has no dependencies. It is distributed under the terms of the Berkeley Software Distribution License.
You can download the latest tagged version which is 0.3 and install it with :
You can also pull the code directly from git :
Tarballs are also available at
github.com/gawen947/rpnc/tarball/master
Though you can only get tagged versions from the master branch, which may be older than what you'll have through git.
Orpie is a great and far more powerful RPN calculator for the console and could be found at pessimization.com/software/orpie. Although it is mean to be used in an interactive way with an ncurse interface. It is written in OCaml.
Everything is passed from the command line. There isn't any interactive mode.
This calculator use Reverse Polish Notation en.wikipedia.org/wiki/Reverse_Polish_notation. For example, consider the following infix expression:
This could be evaluated with rpnc using those arguments:
In order to avoid the shell expander another option is:
Results are printed to standard output. Intermediate results could be shown with the = operator. The program return the number of elements (operators and values) left into the stack. If the whole expression has been evaluated it returns zero.
The operators list follows:
+ Addition - Substraction * Multiplication . Multiplication / Division ^ Raise to a power ** Raise to a power pow Raise to a power atan2 Inverse tangent of a quotient hypot Hypotenuse by the Pythagorean formula mod Modulo operation inv Multiplicative inverse sqrt Square root cbrt Cube root sin Sinus of a radian angle cos Cosine of a radian angle tan Tangent of a radian angle asin Inverse sine in radians acos Inverse cosine in radians atan Inverse tangent in radians sinh Hyperbolic sine cosh Hyperbolic cosine tanh Hyperbolic tangent asinh Inverse hyperbolic sine acosh Inverse hyperbolic cosine atanh Inverse hyperbolic tangent exp Natural exponential exp2 Base two exponential expm1 Natural exponential minus one log Natural logarithm log10 Base-10 logarithm log2 Base two logarithm logb Obtains the exponent log1p Add the natural logarithm of one abs Absolute value erf Error function erfc Complementary error function lgamma Natural logarithm of the absolute value of the gamma function tgamma True gamma function = Show intermediate results pi Pi constant c Speed of light (m/s) e Electron charge (C) me Electron mass (kg) mp Proton mass (kg) G Gravitational constant (N.m^2/kg^2) g Standard gravity (m/s^2) h Planck constant (J.s) hbar Dirac constant (J.s) eps0 Vacuum permittivity (F/m) mu0 Vacuum permeability (H/m) NA Avogadro constant (mol^-1) stdT Standard temperature (K) stdP Standard pression (Pa) INF Infinity +INF Infinity -INF Minus infinity version Display version help Display usage operators Display operators
When an operation raises a floating point exception rpnc exits with an error and displays the offending operator along with a message describing the error. Whether it returns successfully or not, the exit code of rpnc represents the number of items left on the stack when the error occurred.
You can report bugs, send patches and pull request on the github page at
github.com/gawen947/rpnc/issues.
You can also report bugs, send patches and request for new features at my email address
.
Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.