In Unix, is there a built-in calculator?

The following calculator programs exist for Unix systems:

  • bc is the basic calculator. If you enter bc, it will only do integer calculations. However, if you call it with the -l flag (i.e., bc -l), it will do floating-point calculations. For more information on using this calculator, at the Unix prompt, enter:
     man bc
  • dc is the desk calculator. It is very similar to bc, with two major differences: It does floating-point calculations by default, and it uses reverse Polish notation to enter numbers and operators. For example, to add 1 + 2 and to see the result, you would have to type 1 2 + p. Also, dc does not have as many operations available as bc. For more information, at the Unix prompt, enter:
     man dc

To exit bc or dc, press Ctrl-d, or enter quit.

Other third-party calculators may exist on some Unix hosts:

  • calc is another text-based calculator, similar to bc. It is a bit more friendly than bc and can do variable substitutions as well. To find out more about using this program, at the Unix shell prompt, enter:
     man calc
  • xcalc is a graphical scientific calculator that can emulate a TI-30 or an HP-10C scientific calculator. You can run xcalc only in an X Window session.

At Indiana University, for personal or departmental Linux or Unix systems support, see Get help for Linux or Unix at IU.

This is document acta in the Knowledge Base.
Last modified on 2017-05-16 11:50:09.

Contact us

For help or to comment, email the UITS Support Center.