Content-type: text/html Manpage of ralcalc

ralcalc

Section: (1)
Updated: 3 October 2011
Index Return to Main Contents
 

NAME

ralcalc - a simple command line calculator  

SYNOPSIS

ralcalc {-a | --all} | {-h | --help} | {-v | --version} ralcalc [-e | -r] [-f filename] [-i] [-q] [-s prefix] equação = {-a | --all} | {-h | --help} | {-v | --version} = [-e | -r] [-f filename] [-i] [-q] [-s prefix] equação  

DESCRIçãO

ralcalc is a command line calculator designed for very quick calculations where perhaps only a single result is wanted without having to start and then quit a program.

ralcalc is also installed as the = command to make using it even quicker.  

OPçõES

-a, --all
Print out all of the available operators, functions and constants.
-e
Display the result in the "1e-3" form rather than using SI prefixes.
-f
Process a list of calculations from a file. See the FILE INPUT section below for more information.
-h, --help
Display usage, version and contact details.
-i
Process a list of calculations from stdin. See the FILE INPUT section below for more information.
-q
Only display the result (so hide the input and any errors).
-r
Display the result in decimal format with neither SI prefixes nor exponent.
-s
Display the result using a particular SI prefix. This option is ignored if -e or -r is also used.
-v, --version
Display usage, version and contact details.
 

NUMBER FORMAT

Numbers should be input using either "." or "," as a decimal point (this is locale dependent so both may not work in your locale), with no thousands separators.

ralcalc supports SI prefix characters for both input and output:


        = 2u/35
        2u/35 = 57.1429n

Numbers of the form 1e-3 are also supported, where the "e" indicates a power of ten. Don't mix and match SI prefixes and "e" in the same number (although 1e-3n is valid, 1ne-3 is not - avoid both for less confusion).

The SI prefixes supported are: Y, Z, E, P, T, G, M, k, m, u, n, p, f, a, z, y.  

OPERATORS

The simple mathematical operators for addition (+), subtraction (-), multiplication (*, x), division (/) and power (^) are supported, with addition and subtraction having the lowest precedence and power having the highest.


        = 1+2x3
        1+2x3 = 7

        = 1/2^0.5
        1/2^0.5 = 0.707107

Brackets ( (), [] ) can be used to control the order in which statements are processed:


        = [1+2]x3
        [1+2]x3 = 9

Both the square and round brackets can be used and are both directly equivalent, so [1+2)x3 is also valid. Round brackets are more commonly used in mathematics, but the square brackets (and the "x" for multiplication) are included to try to prevent problems with the shell expanding those characters.

ralcalc stores the result of the calculation so that it can be used in the next calculation with the "_" character.


        = 2^0.5
        2^0.5 = 1.41421

        = 1/_
        1/_ = 0.707107
 

FUNçõES

The functions sin, cos, tan, asin, acos, atan, sqrt, log (base 10 logarithm) and ln (natural logarithm) are supported. The trigonometric functions work on radians. The use of brackets is not necessary, but is recommended where precedence may be confusing. The functions have equal precedence to multiplication/division, so care must be taken:


        = sin2x2
        sin2x2 = 1.81859

        = sin[2x2]
        sin[2x2] = -0.756802
 

CONSTANTES

The constants pi (3.14159) and exp (2.71828) can be used and are treated the same as any other number.  

FILE INPUT

A list of calculations can be processed at once by placing them in a file. Each line of the file will be process exactly the same as if ralcalc had been run with those arguments. The file could look like the following (note the lack of the command = or ralcalc):


        2^0.5
        1/_
        238/1064x100

File input is also possible using stdin, i.e. reading interactively directly from the terminal with each line being calculated as normal. To quit, type "q" or "quit" on a new line, use Ctrl-D to indicate the end of file, or use Ctrl-C to cause ralcalc to be terminated.

If either of the file input options are given on the command line, then any calculations given on the command line will be calculated first. If both of the file input options are given, then the calculations from the -f will be carried out first, followed by those from stdin.  

EXEMPLOS

Basic calculation:


        = ln 1.0001
        ln 1.0001 = 99.995u

Exponent number output format:


        = -e ln 1.0001
        ln 1.0001 = 9.9995e-05

Raw number output format:


        = -r ln 1.0001
        ln 1.0001 = 0.000100

Number output format with a specified SI prefix:


        = -s m ln 1.0001
        ln 1.0001 = 0.099995
 

ENVIRONMENT VARIABLES

HOME
Determines where the .ralcalc_result file is stored.
 

EXIT VALUES

0
Success
1
At least one error occurred.
 

FILES

${HOME}/.ralcalc_result
The result of the most recent calculation, which can be accessed in a later calculation using the "_" character. Note that this is not necessarily portable across different machine architectures.
 

DIAGNOSTICS

ralcalc attempts to notify the user of as many errors as possible and indicate where those errors are, if they are user input related.

If an unknown character is included in the equation, an "unknown token" error will be generated. The error marker points to the invalid character.


        = 34/3@2

        Error: 34/3@2
                   ^ unknown token

If an invalid number is included, a "bad number" error will be generated. The error marker points to the end of the invalid number.


        = 3.14.159x2.8^2

        Error: 3.14.159x2.8^2
                      ^ bad number

If the number of open and close brackets do not match, a "mismatched brackets" error will be generated. The error marker position has no significance.


        = 5/[[2+3]*9

        Error: 5/[[2+3]*9
                         ^ mismatched brackets

If an operator appears in an invalid position, an "invalid operator" error will be generated. The error marker indicated the invalid operator.


        = 3^^7

        Error: 3^^7
                 ^ invalid operator

If a bracket appears in an invalid position, an "invalid bracket" error will be generated. This type of error often overlaps with other errors, so there will be a number of messages written to the screen. It is best to fix this error first as it will likely be the root cause of the problem. The error marker indicates the invalid bracket.


        = [2+]3

        Error: [2+]3
                  ^ invalid bracket

        Error: [2+]3
                    ^ invalid operator

If ralcalc is unable to allocate some memory, an "out of memory" error will be generated.

Internal error: If the parser notices two numbers next to each other yet does not generate a "bad number" error, the a "duplicate number" error will be generated. This should never happen.

Internal error: If an unknown error code is passed to the error output function, an "unknown error" will be generated and the invalid error code displayed. This should never happen.  

BUGS

Only a single "-f filename" can be passed at once.

If you find a bug, please submit a report at http://bugs.launchpad.net/ralcalc  

AUTOR

Roger Light <roger@atchoo.org>


 

Index

NAME
SYNOPSIS
DESCRIçãO
OPçõES
NUMBER FORMAT
OPERATORS
FUNçõES
CONSTANTES
FILE INPUT
EXEMPLOS
ENVIRONMENT VARIABLES
EXIT VALUES
FILES
DIAGNOSTICS
BUGS
AUTOR

This document was created by man2html, using the manual pages.
Time: 11:10:15 GMT, October 03, 2011