CloudFlare suffered a massive security issue affecting all of its customers, including Rosetta Code. All passwords not changed since February 19th 2017 have been expired, and session cookie longevity will be reduced until late March.--Michael Mol (talk) 05:15, 25 February 2017 (UTC)


From Rosetta Code
This programming language may be used to instruct a computer to perform a task.
Execution method: Interpreted
Type checking: Static
See Also:

Listed below are all of the tasks on Rosetta Code which have been solved using Bc.
Your Help Needed
If you know Bc, please write code for some of the tasks not implemented in Bc.

bc ("basic calculator") is the standard calculator for Unix systems.
bc boasts unlimited precision, to handle numbers with very many digits.
With the bc language, you can write programs that perform numeric calculations and print the results.

See also 

bc has an interactive mode, which is convenient for brief calculations:

$ bc
2 + 3
2 ^ 200
i = -5
3 - i * 4
obase = 2
ibase = 16

Division and sqrt will not give an infinite number of digits.
The special variable scale controls when to stop.

$ bc
65.9 / 3
scale = 6
65.9 / 3
scale = 60

bc language resembles C language: bc has most of the same operators and control structures ('if', 'while', 'for').
Expressions print themselves, unless they are assignments.
The newline is a statement separator, like the semicolon.

bc has excellent numeric operations, but is a poor language. The original bc, the "Bell Calculator" of Unix V7, translated the program to dc and inherited the limitations of dc.

  • Names of variables, and custom functions, may have only one letter.
  • There is no 'else' branch of an 'if' statement.
  • Relational operators (== <= => != < >) only work in the condition of an 'if', 'while' or 'for' statement.
  • There are no boolean operators (! && ||).

Some newer implementations, like GNU bc and OpenBSD bc, discard these silly limitations, but users can still feel their effects.
OpenBSD says, "a = b < c is interpreted as "(a = b) < c, which is probably not what the programmer intended," and "!a < b is interpreted as !(a < b)".

bc can only print a string, and has no other string operations, so bc cannot do tasks like reverse a string.
bc has no way to read user input, except to go to interactive mode after loading a program.


This category has the following 3 subcategories, out of 3 total.

Pages in category "Bc"

The following 81 pages are in this category, out of 81 total.