bc & dc
bc
and dc
are the 2 calculators that I'll often use when needing access from a terminal.
bc
examples
$ bc
bc 1.06.95
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
Then you can type your calculations:
2
2
5+5
10
dc
examples
$ dc
Syntax to use for your calculations:
2 p
2 p
5 5 +p
10 p
Note that dc
uses postfix, so you'll need to specify operands first, then use an operator such as p
(print) or +
(add)
When you're done you can get out with a Ctrl+C.
Test drive
These calculators are pretty feature rich.
scaling
scale=5
193 * 1/3
64.33333
equations
principal=100
ir = 0.05
years = 5
futurevalue = principal * (1 + ir)^years
futurevalue
127.62800
your examples
8*6-4
44
8*(6-4)
16
calc
If you want something a little more interactive there's calc
.
Example
$ calc
C-style arbitrary precision calculator (version 2.12.4.4)
Calc is open software. For license details type: help copyright
[Type "exit" to exit, or "help" for help.]
; 10+10
20
; 8*6-4
44
; 8*(6-4)
16
;
You can use the up/down arrows to go through past commands and it also has interactive help.
; help
Gives you this:
For more information while running calc, type help followed by one of the
following topics:
topic description
----- -----------
intro introduction to calc
overview overview of calc
help this file
assoc using associations
builtin builtin functions
command top level commands
config configuration parameters
custom information about the custom builtin interface
define how to define functions
environment how environment variables effect calc
errorcodes calc generated error codes
expression expression sequences
file using files
history command history
interrupt how interrupts are handled
list using lists
mat using matrices
...
References