The most basic element in `bc`

is the number. Numbers are
arbitrary precision numbers. This precision is both in the integer part
and the fractional part. All numbers are represented internally in
decimal and all computation is done in decimal. (This version truncates
results from divide and multiply operations.) There are two attributes
of numbers, the length and the scale. The length is the total number of
significant decimal digits in a number and the scale is the total number
of decimal digits after the decimal point. For example, .000001 has a
length of 6 and scale of 6, while 1935.000 has a length of 7 and a scale
of 3.

Numbers are stored in two types of variables, simple variables and
arrays. Both simple variables and array variables are named. Names
begin with a letter followed by any number of letters, digits and
underscores. All letters must be lower case. (Full alphanumeric
names are an extension. In POSIX `bc`

all names are a single
lower case letter.) The type of variable is clear by the context
because all array variable names will be followed by brackets ( [ ] ).

There are four special variables, `scale`, `ibase`, `obase`, and
`last`. `scale` defines how some operations use digits after the
decimal point. The default value of `scale` is 0. `ibase`
and `obase` define the conversion base for input and output
numbers. The default for both input and output is base 10.
`last` (an extension) is a variable that has the value of the last
printed number. These will be discussed in further detail where
appropriate. All of these variables may have values assigned to them
as well as used in expressions.

Comments in `bc`

start with the characters `/*`

and end with
the characters `*/`

. Comments may start anywhere and appear as a
single space in the input. (This causes comments to delimit other
input items. For example, a comment can not be found in the middle of
a variable name.) Comments include any newlines (end of line) between
the start and the end of the comment.

To support the use of scripts for `bc`

, a single line comment has been
added as an extension. A single line comment starts at a `#`

character and continues to the next end of the line. The end of line
character is not part of the comment and is processed normally.

Go to the first, previous, next, last section, table of contents.