Category:Bc: Difference between revisions
Content added Content deleted
m (checking=static, hopl id=1854) |
m (Category:Utility) |
||
Line 5: | Line 5: | ||
}} |
}} |
||
'''bc''' is the standard calculator for [[Unix]] systems. <br> |
|||
'''bc''' 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 [[wp:Bc programming language|Bc programming language]] on Wikipedia.) |
|||
bc boasts unlimited precision, to handle numbers with very many digits. <br> |
|||
With the bc language, you can write programs that perform numeric calculations |
|||
and print the results. |
|||
(See also [[wp:Bc programming language|Bc programming language]] on Wikipedia.) |
|||
⚫ | |||
⚫ | |||
$ '''bc''' |
$ '''bc''' |
||
Line 24: | Line 29: | ||
1111111010000000 |
1111111010000000 |
||
Division and <tt>sqrt</tt> will not give an infinite number of digits. |
Division and <tt>sqrt</tt> will not give an infinite number of digits. <br> |
||
The special variable <tt>scale</tt> controls when to stop. |
|||
$ '''bc''' |
$ '''bc''' |
||
Line 38: | Line 44: | ||
1.414213562373095048801688724209698078569671875376948073176679 |
1.414213562373095048801688724209698078569671875376948073176679 |
||
bc language resembles [[C|C language]]: bc has most of the same operators |
bc language resembles [[C|C language]]: bc has most of the same operators |
||
and control structures ('if', 'while', 'for'). <br> |
|||
Expressions print themselves, unless they are assignments. <br> |
|||
The newline is a statement separator, like the semicolon. |
|||
bc has excellent numeric operations, but is a poor language. |
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. |
* Names of variables, and custom functions, may have only one letter. |
||
Line 47: | Line 58: | ||
* There are no boolean operators (! && ||). |
* There are no boolean operators (! && ||). |
||
Some newer implementations, like [[GNU bc]] and [[OpenBSD bc]], |
Some newer implementations, like [[GNU bc]] and [[OpenBSD bc]], |
||
discard these silly limitations, but users can still feel their effects. <br> |
|||
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, |
bc can only print a string, and has no other string operations, |
||
so bc cannot do tasks like [[reverse a string]]. <br> |
|||
bc has no way to read user input, except to go to interactive mode |
|||
after loading a program. |
|||
[[Category:Mathematical programming languages]] |
[[Category:Mathematical programming languages]] |
||
[[Category:Utility]] |