Name
bc
Synopsis
bc [options] [files]bc is a language (and compiler) whose syntax resembles that of C, but with unlimited-precision arithmetic. bc consists of identifiers, keywords, and symbols, which are briefly described in the following entries. Examples are given at the end.
Interactively perform arbitrary-precision arithmetic or convert numbers from one base to another. Input can be taken from files or read from the standard input. To exit, type quit or EOF.
Options
- -h, --help
Print help message and exit.
- -i, --interactive
Interactive mode.
- -l, --mathlib
Make functions from the math library available.
- -s, --standard
Ignore all extensions, and process exactly as in POSIX.
- -w, --warn
When extensions to POSIX bc are used, print a warning.
- -q, --quiet
Do not display welcome message.
- -v, --version
Print version number.
Identifiers
An identifier is a series of one or more characters. It must begin with a lowercase letter but may also contain digits and underscores. No uppercase letters are allowed. Identifiers are used as names for variables, arrays, and functions. Variables normally store arbitrary-precision numbers. Within the same program you may name a variable, an array, and a function using the same letter. The following identifiers would not conflict:
- x
Variable x.
- x[i]
Element i of array x. i can range from 0 to 2047 and can also be an expression.
- x(y,z)
Call function x with parameters y and z.
Input-output keywords
ibase , obase, scale, and last store a value. Typing them on ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access