ralcalc version 1.3.0
What is ralcalc?
ralcalc is a simple command line calculator designed to take a single line input and produce a result. I also have it installed as the "=" command for even quicker access.
For example:
= 2*9
2*9 = 18
Both the input and output make use of SI prefixes (see http://en.wikipedia.org/wiki/SI_prefix) for easier input and reading of results. Only the common engineering prefixes that are powers a multiple of three are used, so G, M, k, m, u, n, etc.
Numbers of the style 1e-3 are also supported for input.
Version information can be shown with:
= -h
ralcalc -h
See also the man page:
Downloads
Source:
The source is also available as a Mercurial repository at http://hg.atchoo.org/ralcalc. To get a copy use "hg clone http://hg.atchoo.org/ralcalc".
Distro packages:
Operators, Functions and Constants
- + Addition
- - Subtraction
- * x Multiplication (the 'x' is for use when shell expansion may be a problem)
- / Division
- ^ Power
- [] Brackets - increase the precedence of anything within the brackets.
- _ The result of the last ralcalc run (stored in $HOME/.ralcalc_result)
- log The base 10 logarithm.
- ln The natural logarithm.
- sin, cos, tan, asin, acos, atan
- sqrt
- pi (3.14159)
- exp (2.71828)
= 2^.5
2^.5 = 1.41421
= 1/_
1/_ = 707.107m
Precedence
Anything within brackets [] or () is processed first. Within brackets, the order or precedence is ^, * /, + -.
Bugs / Requests
Either contact me directly (see the bottom of the page), or else head to launchpad to submit a new bug report or see existing ones.
Changes
1.3.0 (20081218)
- Preserve some spaces in equations when output. This will compress multiple spaces into a single space, but there will always be at least a single space in the output if there is one in the input.
- Added support for the "-s prefix" option to allow the output to be formatted with a specified SI prefix.
- Fixed bug where SI prefixes entered on their own were treated as a number of value zero. This means that "= 1/p" correctly produces an error now.
- Fixed bug that caused incorrect handling of "sqrt".
- Errors and debug messages are now written on stderr.
- The man page is now written in docbook format to allow easier translation.
- Included Basque translations thanks to Mikel Alzibar.
- Included Polish translations thanks to "pp/bs".
- Included further Brazilian Portugese translations thanks to Enrico Nicoletto.
1.2.4 (20081114)
- Fix bug whereby the precedence wasn't reset correctly after processing a pair of brackets. This would lead to problems with calculations where a power directly followed a close bracket: [2+3]^3.
- Included Brazilian Portugese translations thanks to Ricardo Ichizo.
- Included French translations thanks to Djalil Oulmane.
- Included Spanish translations thanks to Daniel.
1.2.3 (20080916)
- By request, explicit support for square root (sqrt) has been added.
1.2.2 (20080915)
- Added support for the "-a" option which prints out all of the available operators, functions and constants.
1.2.1 (20080718)
- Fixed a string buffer that was being allocated one byte too small and would occasionally lead to spurious "invalid operator" errors.
1.2.0 (20080609)
- Support for sin, cos, tan, asin, acos, atan functions.
- Support for pi and exp constants.
- Inclusion of Hebrew translations thanks to Yaron.
1.1.0 (20080601)
- Added the "-f filename" option. This will process each line of "filename" as though it was typed in at the command line.
- Added the "-i" option which does the same as "-f" but for stdin.
- Added support for log/ln functions.
1.0.1 (20080322)
- Add missing file to the download.
1.0 (20080322)
- Internationalisation and localisation support (want to help translate? Go to Launchpad).
- Build tools improvements.
- Change of licence to GPL.
20070712
- Added the "-r" option to cause the result to use neither SI prefixes nor exponents.
20070702
- Added the "-q" option to produce a quiet output.
- Added the "-e" option to cause the result to be of the form "1e-3" rather than use SI prefixes.
- Fixed the return code on error.
- Fixed negation precedence. No outstanding problems.
20070616
- Precedence is now reset correctly after processing a pair of brackets. Previously, the power in e.g. "= [1+2]^3" was being ignored.
- Brackets are matched better, so "= ]1+2[" is detected as being invalid.
20070614
- Fixed Makefiles on Mac OS X.
- Included missing "=.1" file in download.
- Fixed uninstall target.
20070613
- Added support for 1e3 style numbers.
20070610
- Changed number output format slightly so that we get 0.1 instead of 100m.
- Allow () brackets as well as [].
- Allow "," as a decimal point, depending on locale.
- Fixed operator precedence, number negation excluded.
- Added a man page.
Licence
This code is licensed under GPL licence. See the COPYING file in the download for more
information.
Version Numbers
ralcalc version numbers are constructed like so: x.y.z[.t], where: X is the major version number and a change in this represents a significant and probably incompatible change in functionality. Y is the minor version number and a change represents a general change in functionality. Z is the revision number and represents a change to the code that doesn't introduce new features - so most likely bug fixes. The optional t number is used to indicate string updates when new translations become available for existing versions.
Contact
ralcalc was written in C by Roger Light to fulfill his own needs. He knows that
there are other languages that are better suited to this kind of thing, but he
isn't really bothered about that.
Questions/suggestions should be directed to roger_atchoo_org. Replace the _ with @ and . respectively.