Now and again, laptop customers might have to carry out a fast calculation corresponding to including or multiplying two massive numbers. That is significantly true if the pc consumer works with numbers indirectly: laptop graphics, finance, and lots of different areas. Subtle numerical instruments corresponding to spreadsheets, MATLAB, Mathematica, Octave, and R might be gradual, cumbersome and distracting for such fast calculations. Happily, trendy laptop techniques have numerous instruments that present fast calculators. This text discusses ten broadly accessible and broadly used fast calculators.
(1) MS-DOS SET /A Command Line Calculator DOS PROMPT> SET /A x (op) y
(2) Microsoft Home windows Calc
(UNIX/Linux/Mac OS X/Cygwin/and so forth.)
(3) Bourne Shell command line expressions $[a (op) b]
(4) GNU bc utility (Unix)
(5) GNU Emacs Editor
(6) VIM Textual content Editor Ctrl-R = a (op) b
(7) perl -de 1 perl> print a (op) b
Unix immediate> perl -e ‘print a (op) b;’
(8) python Unix immediate>python Python immediate>a (op) b
Unix immediate> python -c ‘print a (op) b;’
IDLE launches GUI with python interpreter (IDLE accessible for MS Home windows, Mac OS X, and Unix)
(9) ruby Unix immediate>irb Ruby Immediate>a (op) b
Unix immediate>ruby -e ‘print a (op) b;’
(10) Google Calculator Google search field evaluates mathematical expressions!
Bing and Yahoo even have calculators of their search containers!
the place op stands for an arithmetic operation: addition, subtraction, multiplication, division (+, -, *, /)
Some fast calculators help elevating a quantity to an influence, typically “**” or “^”. The “^” image is usually used for the bitwise unique OR as within the C programming language, as an alternative of elevating a quantity to an influence. For instance,
$ python -c 'print 2**3;' 8
The Ten Fast Calculators
Microsoft Home windows and MS-DOS
(1) Home windows CALC COMMAND/UTILITY
The command calc (this system calc.exe) will launch a easy graphical calculator on Microsoft Home windows.
(2) MS-DOS SET /A a (op) b COMMAND
The MS-DOS SET command features as a easy command line calculator that may carry out signed integer arithmetic.
Addition DOS PROMPT> SET /A 1 + 2 3 Multiplication DOS PROMPT> SET /A 3 * 2 6 Subtraction DOS PROMPT> SET /A ten - 8 2 Division DOS PROMPT> SET /A ten / 5 2
Unix together with Mac OS X, Linux, and Cygwin
(3) Bourne Shell Command Line Calculator
The Bourne shell and bash (the Bourne Once more Shell) have a easy built-in command line integer arithmetic calculator considerably just like MS-DOS.
Word: in lots of flavors of Unix, it’s crucial to flee the asterisk with a backslash to carry out multiplication:
Bourne Shell Immediate> echo $[ 2 * 3 ] 6
In any other case, the asterisk is interpreted as a wild card by the shell and the calculation will fail. The Cygwin setting which emulates Unix on MS Home windows doesn’t have this drawback.
One can assign the outcomes of the calculation to an setting variable through the use of the equal signal:
a=$[2 + 3] echo $a 5
Word: there is no such thing as a house between the variable title (e.g. “a”) and the equal signal. “a = $[2 + 3]” offers an error.
NOTE: This solely works for integer arithmetic. Floating level offers 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’s preinstalled on many Unix techniques. Though it’s not a part of the bottom set up, it may be put in within the Cygwin setting. Along with primary arithmetic, it has a small math library with just a few widespread trigonometric and transcendental features which might be invoked with the -l choice: bc -l
bc has an annoying peculiarity, a considerably mysterious built-in variable scale which appears to correspond to the variety of digits displayed after the decimal level within the outcomes of a division operation. By default, scale is about to zero (0). What this implies is that, by default, division (and solely division) offers the outcomes of integer division; there are not any decimals after the decimal level.
10/3 = 3
Nevertheless, if scale is about to a optimistic quantity, the outcomes 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 Textual content Editor
The broadly used and broadly accessible GNU Emacs textual content editor has each a classy calculator mode with a major studying curve and an easy-to-use fast calculator command.
-x quick-calc a (op) b
In most variations of GNU Emacs, the results of the short calculation is positioned within the Emacs “kill ring” and might be then pasted into the present edit buffer through the use of Ctrl-y (“yank”).
(6) VIM Textual content Editor
The broadly used and broadly accessible vim textual content editor has a fast calculator function.
Within the VIM INSERT Mode, kind Ctrl-R (nothing seen occurs) adopted by the equal signal “=”. An equal signal will seem on the decrease left nook of the VIM window. Then, enter the mathematical expression to judge:
= 2 + 3
Press the RETURN or ENTER key and VIM will paste the results of the calculation into the file being edited. VIM can do each integer and floating level calculation. Use easy numbers corresponding to “2 + 3” to get integer outcomes. Use numbers with decimal factors corresponding to “2.1 + 3.4” to get floating level outcomes.
PERL, PYTHON, and RUBY
Virtually all Unix techniques now include the perl programming language preinstalled. Most Unix techniques now include the python scripting language preinstalled. Many Unix techniques include the ruby scripting language preinstalled. It’s straightforward to put in perl, python, and ruby on any Unix system. All can be found as native functions for MS-Home windows techniques in addition to via the Cygwin setting which emulates Unix on MS-Home windows techniques. All of those scripting languages might be run on the command line or interactively as easy fast calculators.
The perl scripting language can be utilized as a fast calculator.
on the Unix command line
$ perl -e 'print 2 + 3;' $ perl -e 'print 2 * 3;' $ perl -e 'print 2 - 3;' $ perl -e 'print 2 / 3;'
$ perl -de 1 Loading DB routines from perl5db.pl model 1.32 Editor help accessible. Enter h or `h h' for assist, or `man perldebug' for extra assist. principal::(-e:1): 1 DB 2+2 DB print 2+2 4 DB print 2/3 0.666666666666667 DB
The python programming langauge can be utilized as a fast calculator.
on the Unix command line
[email protected] ~ $ python -c 'print 2 + 3;' 5 [email protected] ~ $ python -c 'print 2 * 3;' 6 [email protected] ~ $ python -c 'print 2 - 3;' -1 [email protected] ~ $ python -c 'print 2 / 3;' 0 [email protected] ~ $ python -c 'print 2.0 / 3.0;' 0.666666666667
$ python Python 2.6.8 (unknown, Jun 9 2012, 11:30:32) [GCC 4.5.3] on cygwin Kind "assist", "copyright", "credit" or "license" for extra info. >>> 2 + 3 5 >>> 2 * 3 6 >>> 2 - 3 -1 >>> 2 / 3 0 >>> 2.0 / 3.0 0.66666666666666663 >>> give up()
NOTE that Python treats easy numbers corresponding to 2 and three as integers. “2 / 3” is integer division and yields zero (0). Python treats numbers with decimal factors corresponding to 2.0 and three.0 as floating level numbers. “2.0 / 3.0” is floating level division and yields 0.66666666.
Python additionally comes with an interactive GUI setting often known as IDLE (after comic Eric Idle of Monty Python fame)
NOTE that Python below IDLE treats easy numbers corresponding to 2 and three as floating level numbers, not integers as on the command line. Sadly, laptop packages typically comprise these inconsistencies and quirks which might generally chunk the consumer, particularly in mathematical or numerical tasks.
The ruby programming language can be utilized as a fast calculator.
on the Unix command line:
$ ruby -e 'print 2 + 3;' 5 [email protected] ~ $ ruby -e 'print 2 * 3;' 6 [email protected] ~ $ ruby -e 'print 2 - 3;' -1 [email protected] ~ $ ruby -e 'print 2 / 3;' 0 J[email protected] ~ $ ruby -e 'print 2.0 / 3.0;' 0.666666666666667
interactively (use the irb command for interactive ruby):
$ irb irb(principal):001:0> 2 + 3 => 5 irb(principal):002:0> 2 * 3 => 6 irb(principal):003:0> 2 - 3 => -1 irb(principal):004:0> 2 / 3 => 0 irb(principal):005:0> 2.0 / 3.0 => 0.666666666666667 irb(principal):006:0> give up()
NOTE that Ruby, like Python, treats easy numbers corresponding to 2 and three as integers. “2 / 3” is integer division and yields zero (0). Ruby treats numbers with decimal factors corresponding to 2.0 and three.0 as floating level numbers. “2.0 / 3.0” is floating level division and yields 0.66666666.
Google has a calculator that evaluates mathematical expressions constructed into the search field. Yahoo and BING even have calculators constructed into their search containers.
On this article, ten fast calculators for computer systems customers had been introduced and their primary use defined.
The fast calculators are applicable for infrequent fast calculations corresponding to including or multiplying two massive numbers. They are going to work greatest if the pc consumer practices and may use the short calculator of his/her selection rapidly and simply — “second nature”.
Fast calculators are sometimes quicker and fewer cumbersome than subtle numerical instruments corresponding to spreadsheets like Excel or mathematical scripting languages corresponding to MATLAB or Octave for infrequent fast calculations corresponding to including or multiplying two massive numbers. Nevertheless, subtle numerical and mathematical instruments are higher for big quantity crunching tasks.
© 2012 John F. McGowan
Concerning the Creator
John F. McGowan, Ph.D. solves issues utilizing arithmetic and mathematical software program, together with growing video compression and speech recognition applied sciences. He has in depth expertise growing software program in C, C++, Visible Fundamental, Mathematica, MATLAB, and lots of different programming languages. He’s in all probability greatest recognized for his AVI Overview, an Web FAQ (Often Requested Questions) on the Microsoft AVI (Audio Video Interleave) file format. He has labored as a contractor at NASA Ames Analysis Heart concerned within the analysis and growth of picture and video processing algorithms and know-how. He has printed articles on the origin and evolution of life, the exploration of Mars (anticipating the invention of methane on Mars), and low cost entry to house. He has a Ph.D. in physics from the College of Illinois at Urbana-Champaign and a B.S. in physics from the California Institute of Know-how (Caltech). He might be reached at [email protected].