bc [options] [files]

Interactively performs arbitrary-precision arithmetic or converts numbers from one base to another. Input can be taken from files or read from the standard input. To exit, type quit or EOF.



Don’t invoke dc; compile only. (Because bc is a preprocessor for dc, bc normally invokes dc.)


Make available functions from the math library.


Quiet, don’t print welcome message.


Don’t use extensions to POSIX bc.


Print version number.


Warn if extensions are used.

bc is a language (and compiler) whose syntax resembles that of C. bc consists of identifiers, keywords, and symbols, which are briefly described here. Examples follow at the end of this section.


An identifier is a single character, consisting of the lowercase letters a-z. Identifiers are used as names for variables, arrays, and functions. Within the same program, you may name a variable, an array, and a function using the same letter. The following identifiers would not conflict:


Variable x.


Element i of array x. i can range from 0 to 2047 and can also be an expression.


Call function x with parameters y and z.

Input/output keywords

ibase, obase, and scale each store a value. Typing them on a line by themselves displays their current value. More commonly, you would change their values through assignment. Letters A-F are treated as digits whose values are 10-15.

ibase = n

Numbers that are input (e.g., typed) are read as base n (default is 10).

obase = n

Numbers ...

Get Mac OS X Panther in a Nutshell, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.