bc.1 (259785) | bc.1 (265533) |
---|---|
1.\" $FreeBSD: stable/10/usr.bin/bc/bc.1 259785 2013-12-23 20:20:46Z delphij $ 2.\" $OpenBSD: bc.1,v 1.25 2010/01/02 19:48:56 schwarze Exp $ | 1.\" $FreeBSD: stable/10/usr.bin/bc/bc.1 265533 2014-05-07 08:06:54Z delphij $ 2.\" $OpenBSD: bc.1,v 1.30 2014/01/14 07:42:42 jmc Exp $ |
3.\" 4.\" Copyright (C) Caldera International Inc. 2001-2002. 5.\" All rights reserved. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code and documentation must retain the above --- 19 unchanged lines hidden (view full) --- 30.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 33.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34.\" POSSIBILITY OF SUCH DAMAGE. 35.\" 36.\" @(#)bc.1 6.8 (Berkeley) 8/8/91 37.\" | 3.\" 4.\" Copyright (C) Caldera International Inc. 2001-2002. 5.\" All rights reserved. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code and documentation must retain the above --- 19 unchanged lines hidden (view full) --- 30.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 33.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34.\" POSSIBILITY OF SUCH DAMAGE. 35.\" 36.\" @(#)bc.1 6.8 (Berkeley) 8/8/91 37.\" |
38.Dd December 6, 2013 | 38.Dd April 16, 2014 |
39.Dt BC 1 40.Os 41.Sh NAME 42.Nm bc 43.Nd arbitrary-precision arithmetic language and calculator 44.Sh SYNOPSIS 45.Nm bc 46.Op Fl chlv --- 88 unchanged lines hidden (view full) --- 135is ignored within numbers. 136.Pp 137Operators 138.Pp 139The following arithmetic and logical operators can be used. 140The semantics of the operators is the same as in the C language. 141They are listed in order of decreasing precedence. 142Operators in the same group have the same precedence. | 39.Dt BC 1 40.Os 41.Sh NAME 42.Nm bc 43.Nd arbitrary-precision arithmetic language and calculator 44.Sh SYNOPSIS 45.Nm bc 46.Op Fl chlv --- 88 unchanged lines hidden (view full) --- 135is ignored within numbers. 136.Pp 137Operators 138.Pp 139The following arithmetic and logical operators can be used. 140The semantics of the operators is the same as in the C language. 141They are listed in order of decreasing precedence. 142Operators in the same group have the same precedence. |
143.Bl -column -offset indent "= += \-= *= /= %= ^=" "Associativity" \ 144"multiply, divide, modulus" | 143.Bl -column "= += \-= *= /= %= ^=" "Associativity" "multiply, divide, modulus" -offset indent |
145.It Sy "Operator" Ta Sy "Associativity" Ta Sy "Description" 146.It "++ \-\-" Ta "none" Ta "increment, decrement" 147.It "\-" Ta "none" Ta "unary minus" 148.It "^" Ta "right" Ta "power" 149.It "* / %" Ta "left" Ta "multiply, divide, modulus" 150.It "+ \-" Ta "left" Ta "plus, minus" 151.It "= += -= *= /= %= ^=" Ta "right" Ta "assignment" 152.It "== <= >= != < >" Ta "none" Ta "relational" 153.It "!" Ta "none" Ta "boolean not" 154.It "&&" Ta "left" Ta "boolean and" 155.It "||" Ta "left" Ta "boolean or" 156.El 157.Pp 158Note the following: 159.Bl -bullet -offset indent 160.It 161The relational operators may appear in any expression. 162The | 144.It Sy "Operator" Ta Sy "Associativity" Ta Sy "Description" 145.It "++ \-\-" Ta "none" Ta "increment, decrement" 146.It "\-" Ta "none" Ta "unary minus" 147.It "^" Ta "right" Ta "power" 148.It "* / %" Ta "left" Ta "multiply, divide, modulus" 149.It "+ \-" Ta "left" Ta "plus, minus" 150.It "= += -= *= /= %= ^=" Ta "right" Ta "assignment" 151.It "== <= >= != < >" Ta "none" Ta "relational" 152.It "!" Ta "none" Ta "boolean not" 153.It "&&" Ta "left" Ta "boolean and" 154.It "||" Ta "left" Ta "boolean or" 155.El 156.Pp 157Note the following: 158.Bl -bullet -offset indent 159.It 160The relational operators may appear in any expression. 161The |
163.St -p1003.2 | 162.St -p1003.1-2008 |
164standard only allows them in the conditional expression of an 165.Sq if , 166.Sq while 167or 168.Sq for 169statement. 170.It 171The relational operators have a lower precedence than the assignment --- 165 unchanged lines hidden (view full) --- 337.Pp 338prints approximate values of the exponential function of 339the first ten integers. 340.Bd -literal -offset indent 341$ bc -l -e 'scale = 500; 2 * a(2^10000)' -e quit 342.Ed 343.Pp 344prints an approximation of pi. | 163standard only allows them in the conditional expression of an 164.Sq if , 165.Sq while 166or 167.Sq for 168statement. 169.It 170The relational operators have a lower precedence than the assignment --- 165 unchanged lines hidden (view full) --- 336.Pp 337prints approximate values of the exponential function of 338the first ten integers. 339.Bd -literal -offset indent 340$ bc -l -e 'scale = 500; 2 * a(2^10000)' -e quit 341.Ed 342.Pp 343prints an approximation of pi. |
344.Sh COMMAND LINE EDITING 345.Nm 346supports interactive command line editing, via the 347.Xr editline 3 348library. 349It is enabled by default if input is from a tty. 350Previous lines can be recalled and edited with the arrow keys, 351and other GNU Emacs-style editing keys may be used as well. 352.Pp 353The 354.Xr editline 3 355library is configured with a 356.Pa .editrc 357file \- refer to 358.Xr editrc 5 359for more information. |
|
345.Sh FILES 346.Bl -tag -width /usr/share/misc/bc.library -compact 347.It Pa /usr/share/misc/bc.library 348math library, read when the 349.Fl l 350option is specified on the command line. 351.El 352.Sh COMPATIBILITY 353The 354.Fl q 355and 356.Fl Fl quiet 357options are no-ops for compatibility with some other implementations of 358.Nm 359and their use is discouraged. 360.Sh SEE ALSO 361.Xr dc 1 | 360.Sh FILES 361.Bl -tag -width /usr/share/misc/bc.library -compact 362.It Pa /usr/share/misc/bc.library 363math library, read when the 364.Fl l 365option is specified on the command line. 366.El 367.Sh COMPATIBILITY 368The 369.Fl q 370and 371.Fl Fl quiet 372options are no-ops for compatibility with some other implementations of 373.Nm 374and their use is discouraged. 375.Sh SEE ALSO 376.Xr dc 1 |
362.Pp 363"BC \- An Arbitrary Precision Desk-Calculator Language", 364.Pa /usr/share/doc/usd/06.bc/ . | |
365.Sh STANDARDS 366The 367.Nm 368utility is compliant with the 369.St -p1003.1-2008 370specification. 371.Pp 372The flags | 377.Sh STANDARDS 378The 379.Nm 380utility is compliant with the 381.St -p1003.1-2008 382specification. 383.Pp 384The flags |
373.Op Fl ce | 385.Op Fl ce , 386as well as the parts noted above, |
374are extensions to that specification. 375.Sh HISTORY 376The 377.Nm 378command first appeared in 379.At v6 . 380A complete rewrite of the 381.Nm --- 21 unchanged lines hidden --- | 387are extensions to that specification. 388.Sh HISTORY 389The 390.Nm 391command first appeared in 392.At v6 . 393A complete rewrite of the 394.Nm --- 21 unchanged lines hidden --- |