From time to time, computer users may need to perform a quick calculation such as adding or multiplying two large numbers. This is particularly true if the computer user works with numbers in some way: computer graphics, finance, and many other areas. Sophisticated numerical tools such as spreadsheets, MATLAB, Mathematica, Octave, and R can be slow, cumbersome and distracting for such quick calculations. Fortunately, modern computer systems have a large number of tools that provide quick calculators. This article discusses ten widely available and widely used quick calculators.

**Quick Reference**

(1) MS-DOS SET /A Command Line Calculator DOS PROMPT> SET /A x (*op*) y

(2) Microsoft Windows Calc

(UNIX/Linux/Mac OS X/Cygwin/etc.)

(3) Bourne Shell command line expressions $[a (*op*) b]

(4) GNU *bc* utility (Unix)

(5) GNU Emacs Editor

(6) VIM Text Editor Ctrl-R = a (*op*) b

(7) perl -de 1 perl> print a (*op*) b

Unix prompt> perl -e ‘print a (*op*) b;’

(8) python Unix prompt>python Python prompt>a (*op*) b

Unix prompt> python -c ‘print a (*op*) b;’

IDLE launches GUI with python interpreter (IDLE available for MS Windows, Mac OS X, and Unix)

(9) ruby Unix prompt>irb Ruby Prompt>a (*op*) b

Unix prompt>ruby -e ‘print a (*op*) b;’

(10) Google Calculator Google search box evaluates mathematical expressions!

Bing and Yahoo also have calculators in their search boxes!

where * op* stands for an arithmetic operation: addition, subtraction, multiplication, division (+, -, *, /)

Some quick calculators support raising a number to a power, often “**” or “^”. The “^” symbol is sometimes used for the bitwise exclusive OR as in the C programming language, instead of raising a number to a power. For example,

$ python -c 'print 2**3;' 8

**The Ten Quick Calculators**

**Microsoft Windows and MS-DOS**

**(1) Windows CALC COMMAND/UTILITY**

The command calc (the program calc.exe) will launch a simple graphical calculator on Microsoft Windows.

DOS PROMPT>calc

**(2) MS-DOS SET /A a ( op) b COMMAND**

The MS-DOS SET command functions as a simple command line calculator that can perform signed integer arithmetic.

Addition DOS PROMPT> SET /A 1 + 2 3 Multiplication DOS PROMPT> SET /A 3 * 2 6 Subtraction DOS PROMPT> SET /A 10 - 8 2 Division DOS PROMPT> SET /A 10 / 5 2

**Unix including Mac OS X, Linux, and Cygwin**

**(3) Bourne Shell Command Line Calculator**

The Bourne shell and bash (the Bourne Again Shell) have a simple built-in command line integer arithmetic calculator somewhat similar to MS-DOS.

Note: in many flavors of Unix, it is necessary to escape the asterisk with a backslash to perform multiplication:

Bourne Shell Prompt> echo $[ 2 \* 3 ] 6

Otherwise, the asterisk is interpreted as a wild card by the shell and the calculation will fail. The Cygwin environment which emulates Unix on MS Windows does not have this problem.

One can assign the results of the calculation to an environment variable by using the equal sign:

a=$[2 + 3] echo $a 5

Note: there is no space between the variable name (e.g. “a”) and the equal sign. “a = $[2 + 3]” gives an error.

NOTE: This only works for integer arithmetic. Floating point gives an error:

$ echo $[2.1*3.1] -bash: 2.1*3.1: syntax error: invalid arithmetic operator (error token is ".1*3.1")

**(4) GNU bc Utility (Unix)**

The GNU *bc* utility is an arbitrary precision calculator language. It is preinstalled on many Unix systems. Although it is not part of the base installation, it can be installed in the Cygwin environment. In addition to basic arithmetic, it has a small math library with a few common trigonometric and transcendental functions which can be invoked with the -l option: *bc -l*

*bc* has an annoying peculiarity, a somewhat mysterious built-in variable *scale* which seems to correspond to the number of digits displayed after the decimal point in the results of a division operation. By default, scale is set to zero (0). What this means is that, by default, division (and only division) gives the results of integer division; there are no decimals after the decimal point.

10/3 = 3

However, if scale is set to a positive number, the results of the division operation are reported with the requested precision.

scale = 2 10/3 = 3.33 scale = 3 10/3 = 3.333

**(5) GNU Emacs Text Editor**

The widely used and widely available GNU Emacs text editor has both a sophisticated calculator mode with a significant learning curve and an easy-to-use quick calculator command.

-x quick-calc a ( op) b

In most versions of GNU Emacs, the result of the quick calculation is placed in the Emacs “kill ring” and can be then pasted into the current edit buffer by using Ctrl-y (“yank”).

**(6) VIM Text Editor**

The widely used and widely available vim text editor has a quick calculator feature.

In the VIM INSERT Mode, type Ctrl-R (nothing visible happens) followed by the equal sign “=”. An equal sign will appear at the lower left corner of the VIM window. Then, enter the mathematical expression to evaluate:

= 2 + 3

Press the RETURN or ENTER key and VIM will paste the result of the calculation into the file being edited. VIM can do both integer and floating point calculation. Use simple numbers such as “2 + 3” to get integer results. Use numbers with decimal points such as “2.1 + 3.4” to get floating point results.

** PERL, PYTHON, and RUBY**

Almost all Unix systems now come with the perl programming language preinstalled. Most Unix systems now come with the python scripting language preinstalled. Many Unix systems come with the ruby scripting language preinstalled. It is easy to install perl, python, and ruby on any Unix system. All are available as native applications for MS-Windows systems as well as through the Cygwin environment which emulates Unix on MS-Windows systems. All of these scripting languages can be run at the command line or interactively as simple quick calculators.

**(7) PERL**

The perl scripting language can be used as a quick calculator.

at the Unix command line

$ perl -e 'print 2 + 3;' $ perl -e 'print 2 * 3;' $ perl -e 'print 2 - 3;' $ perl -e 'print 2 / 3;'

interactively:

$ perl -de 1 Loading DB routines from perl5db.pl version 1.32 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(-e:1): 1 DB<1> 2+2 DB<2> print 2+2 4 DB<3> print 2/3 0.666666666666667 DB<4>

**(8) PYTHON**

The python programming langauge can be used as a quick calculator.

at the Unix command line

John@John-HP ~ $ python -c 'print 2 + 3;' 5 John@John-HP ~ $ python -c 'print 2 * 3;' 6 John@John-HP ~ $ python -c 'print 2 - 3;' -1 John@John-HP ~ $ python -c 'print 2 / 3;' 0 John@John-HP ~ $ python -c 'print 2.0 / 3.0;' 0.666666666667

interactively

$ python Python 2.6.8 (unknown, Jun 9 2012, 11:30:32) [GCC 4.5.3] on cygwin Type "help", "copyright", "credits" or "license" for more information. >>> 2 + 3 5 >>> 2 * 3 6 >>> 2 - 3 -1 >>> 2 / 3 0 >>> 2.0 / 3.0 0.66666666666666663 >>> quit()

NOTE that Python treats simple numbers such as 2 and 3 as integers. “2 / 3” is integer division and yields zero (0). Python treats numbers with decimal points such as 2.0 and 3.0 as floating point numbers. “2.0 / 3.0” is floating point division and yields 0.66666666.

Python also comes with an interactive GUI environment known as IDLE (after comedian Eric Idle of Monty Python fame)

NOTE that Python under IDLE treats simple numbers such as 2 and 3 as floating point numbers, not integers as at the command line. Sadly, computer programs often contain these inconsistencies and quirks which can sometimes bite the user, especially in mathematical or numerical projects.

**(9) RUBY**

The ruby programming language can be used as a quick calculator.

at the Unix command line:

$ ruby -e 'print 2 + 3;' 5 John@John-HP ~ $ ruby -e 'print 2 * 3;' 6 John@John-HP ~ $ ruby -e 'print 2 - 3;' -1 John@John-HP ~ $ ruby -e 'print 2 / 3;' 0 John@John-HP ~ $ ruby -e 'print 2.0 / 3.0;' 0.666666666666667

interactively (use the irb command for interactive ruby):

$ irb irb(main):001:0> 2 + 3 => 5 irb(main):002:0> 2 * 3 => 6 irb(main):003:0> 2 - 3 => -1 irb(main):004:0> 2 / 3 => 0 irb(main):005:0> 2.0 / 3.0 => 0.666666666666667 irb(main):006:0> quit()

NOTE that Ruby, like Python, treats simple numbers such as 2 and 3 as integers. “2 / 3” is integer division and yields zero (0). Ruby treats numbers with decimal points such as 2.0 and 3.0 as floating point numbers. “2.0 / 3.0” is floating point division and yields 0.66666666.

**(10) GOOGLE/YAHOO/BING**

Google has a calculator that evaluates mathematical expressions built into the search box. Yahoo and BING also have calculators built into their search boxes.

**Conclusion**

In this article, ten quick calculators for computers users were presented and their basic use explained.

The quick calculators are appropriate for occasional quick calculations such as adding or multiplying two large numbers. They will work best if the computer user practices and can use the quick calculator of his/her choice quickly and easily — “second nature”.

Quick calculators are often faster and less cumbersome than sophisticated numerical tools such as spreadsheets like Excel or mathematical scripting languages such as MATLAB or Octave for occasional quick calculations such as adding or multiplying two large numbers. However, sophisticated numerical and mathematical tools are better for large number crunching projects.

© 2012 John F. McGowan

**About the Author**

*John F. McGowan, Ph.D.* solves problems using mathematics and mathematical software, including developing video compression and speech recognition technologies. He has extensive experience developing software in C, C++, Visual Basic, Mathematica, MATLAB, and many other programming languages. He is probably best known for his AVI Overview, an Internet FAQ (Frequently Asked Questions) on the Microsoft AVI (Audio Video Interleave) file format. He has worked as a contractor at NASA Ames Research Center involved in the research and development of image and video processing algorithms and technology. He has published articles on the origin and evolution of life, the exploration of Mars (anticipating the discovery of methane on Mars), and cheap access to space. He has a Ph.D. in physics from the University of Illinois at Urbana-Champaign and a B.S. in physics from the California Institute of Technology (Caltech). He can be reached at jmcgowan11@earthlink.net.

#### Get more stuff like this

Get interesting math updates directly in your inbox.

2/3 returns a floating point number in Python 3.0 and later versions, but it returns an integer in previous versions.

I always in bc in Unix (pre-GNU days). It was simple, fairly straightforward, could be easily piped together with sed scripts to extract numeric data from text reports and script operations, and, best of all, its name was my initials!

I can’t really see why the superb WolframAlpha (http://www.wolframalpha.com/) is omitted from the list. It outpowers each one of these by far.

My own favorites are Landon Curt Noll’s calc:

http://isthe.com/chongo/tech/comp/calc/index.html

and a lovely command line RPN calculator (no longer under development, alas) called orpie:

http://pessimization.com/software/orpie/

I always install calc on a new Linux installation.

Also Crimson Editor/Emerald Editor (a text editor for Windows) have the ability to compute little expressions pressing CTRL+Enter:

1+2 CTRL+Enter

$ans = 3

Usually, I use it or WolframAlpha (or Google) depends

Usually, I use it or WolframAlpha (or Google) depends by the kind of calculus.

While this post references a typical calculator, I’d like to recommend http://www.standarddeviationcalculator.com for standard deviation problems. The site is thorough.

And, if you are looking for a variety of calculators, I use http://www.onlinecalculatorfree.org – The site offers approximately 50 calculators in addition to a basic math calculator

Ruby is one of the good program for computer. I have little knowledge about this program. Thanks for sharing ruby code for this nice calculator.

Thanks for informations.

Przy okazji zapraszam na .