Calcolatrice bc

bc, la calcolatrice a precisione arbitraria: numeri con tutte le cifre che vuoi, funzioni e una libreria matematica (bc -l). Scrivi bc e poi espressioni come 2^200 o sqrt(2).

versione 7.1.0 · Licenza: BSD-2-Clause · Sito del progetto

bc

A cosa serve

bc è la calcolatrice a precisione arbitraria dei sistemi Unix: i numeri possono avere tutte le cifre che vuoi, prima e dopo la virgola. Ha variabili, if, cicli, funzioni definite da te e, con -l, una libreria matematica (seno, coseno, arcotangente, logaritmo, esponenziale). Questa è la versione di Gavin Howard.

Come si usa

Comando Cosa fa
bc apre la calcolatrice interattiva (>>>)
bc -l con la libreria matematica e 20 decimali
bc conti.bc esegue un file dalla cartella home, poi resta interattiva
echo "2^64" \| bc calcola al volo con una pipe della shell

Scrivi un'espressione e premi Invio:

>>> 2^200
1606938044258990275541962092341162602522202993782792835301376
>>> scale = 30
>>> 1/7
.142857142857142857142857142857
>>> sqrt(2)
1.414213562373095048801688724209
>>> obase = 16
>>> 255
FF

Con bc -l: 4*a(1) è pi greco, s(x) seno, c(x) coseno, l(x) logaritmo naturale, e(x) esponenziale. Una funzione tua:

define fatt(n) {
  if (n < 2) return 1
  return n * fatt(n - 1)
}
fatt(50)

Per uscire: quit, oppure EOF.

Limiti

Un errore (per esempio 1/0) nel prompt viene segnalato e si continua; un errore dentro un file lo interrompe. Niente cronologia né editor di riga. Memoria disponibile: fino a 8 MB.

Nel Terminale

bc calculator

bc, the arbitrary-precision calculator: numbers with as many digits as you want, functions, and a math library (bc -l). Type bc and write expressions like 2^200 or sqrt(2).

version 7.1.0 · License: BSD-2-Clause · Project site

bc

What it is

bc is the Unix arbitrary-precision calculator: numbers can have as many digits as you like, before and after the point. It has variables, if, loops, your own functions and, with -l, a math library (sine, cosine, arctangent, logarithm, exponential). This is Gavin Howard's version.

How to use it

Command What it does
bc opens the interactive calculator (>>>)
bc -l with the math library and 20 decimals
bc sums.bc runs a file from the home folder, then stays interactive
echo "2^64" \| bc quick calculation through a shell pipe

Type an expression and press Enter:

>>> 2^200
1606938044258990275541962092341162602522202993782792835301376
>>> scale = 30
>>> 1/7
.142857142857142857142857142857
>>> sqrt(2)
1.414213562373095048801688724209
>>> obase = 16
>>> 255
FF

With bc -l: 4*a(1) is pi, s(x) sine, c(x) cosine, l(x) natural log, e(x) exponential. A function of your own:

define fact(n) {
  if (n < 2) return 1
  return n * fact(n - 1)
}
fact(50)

To quit: quit, or EOF.

Limits

An error at the prompt (e.g. 1/0) is reported and you carry on; an error inside a file stops it. No history or line editor. Memory: up to 8 MB.

In the Terminal