Ten Great Quick Calculators for Computer Users

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 -x quick-calc Ctrl-y to paste result of calculator into Emacs buffer.
(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
MS Windows Calculator GUI

MS Windows Calculator GUI

(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")
Cygwin Bash Command Line Calculator

Cygwin Bash Command Line Calculator

(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
GNU bc in console window

GNU bc in console window

(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”).

GNU Emacs Quick Calc Command Screenshot

GNU Emacs Quick Calc Command Screenshot

GNU Emacs Quick Calc Step Two Screenshot

GNU Emacs Quick Calc Step Two Screenshot

GNU Emacs Quick Calc Step Three (Result)

GNU Emacs Quick Calc Step Three (Result)

(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.

VIM Quick Calculator Step One Window Only

VIM Quick Calculator Step One Window Only

VIM Quick Calc Step Two Window Only

VIM Quick Calc Step Two Window Only

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)

IDLE Python GUI Window Only

IDLE Python GUI Window Only

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.

GOOGLE Quick Calculator Screenshot

GOOGLE Quick Calculator Screenshot

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.

8 Comments

  1. David Radcliffe June 18, 2012
  2. Barry Cunningham June 18, 2012
  3. Liiv June 19, 2012
  4. Glenn Becker June 19, 2012
  5. gialloporpora June 20, 2012
  6. Jarrod July 22, 2012
  7. snöslunga September 15, 2013
  8. MrMath June 16, 2015

Leave a Reply

Join thousands of
math enthusiasts

Get free math updates directly in your inbox.