Print this page
11622 clean up rarer mandoc lint warnings

Split Close
Expand all
Collapse all
          --- old/usr/src/man/man1/bc.1
          +++ new/usr/src/man/man1/bc.1
↓ open down ↓ 40 lines elided ↑ open up ↑
  41   41  .\"
  42   42  .\"
  43   43  .\" Copyright 1989 AT&T
  44   44  .\" Portions Copyright (c) 1992, X/Open Company Limited.  All Rights Reserved.
  45   45  .\" Copyright (c) 2003, Sun Microsystems, Inc.  All Rights Reserved.
  46   46  .\"
  47   47  .TH BC 1 "Aug 29, 2003"
  48   48  .SH NAME
  49   49  bc \- arbitrary precision arithmetic language
  50   50  .SH SYNOPSIS
  51      -.LP
  52   51  .nf
  53   52  \fB/usr/bin/bc\fR [\fB-c\fR] [\fB-l\fR] [\fIfile\fR]...
  54   53  .fi
  55   54  
  56   55  .LP
  57   56  .nf
  58   57  \fB/usr/xpg6/bin/bc\fR [\fB-c\fR] [\fB-l\fR] [\fIfile\fR]...
  59   58  .fi
  60   59  
  61   60  .SH DESCRIPTION
  62      -.sp
  63      -.LP
  64   61  The \fBbc\fR utility implements an arbitrary precision calculator. It takes
  65   62  input from any files given, then reads from the standard input. If the standard
  66   63  input and standard output to \fBbc\fR are attached to a terminal, the
  67   64  invocation of \fBbc\fR is  \fIinteractive\fR, causing behavioral constraints
  68   65  described in the following sections. \fBbc\fR processes a language that
  69   66  resembles C and is a preprocessor for the desk calculator program \fBdc\fR,
  70   67  which it invokes automatically unless the \fB-c\fR option is specified. In this
  71   68  case the \fBdc\fR input is sent to the standard output instead.
  72   69  .SH USAGE
  73      -.sp
  74      -.LP
  75   70  The syntax for  \fBbc\fR programs is as follows:
  76   71  .sp
  77   72  .ne 2
  78   73  .na
  79   74  \fB\fIL\fR\fR
  80   75  .ad
  81   76  .RS 5n
  82   77  Means a letter \fBa\fR\(mi\fBz\fR,
  83   78  .RE
  84   79  
↓ open down ↓ 10 lines elided ↑ open up ↑
  95   90  .sp
  96   91  .ne 2
  97   92  .na
  98   93  \fB\fIS\fR\fR
  99   94  .ad
 100   95  .RS 5n
 101   96  Means a statement.
 102   97  .RE
 103   98  
 104   99  .SS "Comments"
 105      -.sp
 106      -.LP
 107  100  Enclosed in \fB/*\fR and \fB*/\fR.
 108  101  .SS "Names (Operands)"
 109      -.br
 110  102  .in +2
 111  103  Simple variables: \fIL\fR.
 112  104  .in -2
 113  105  .br
 114  106  .in +2
 115  107  Array elements: \fIL\fR [ \fIE\fR ] (up to \fBBC_DIM_MAX\fR dimensions).
 116  108  .in -2
 117  109  .br
 118  110  .in +2
 119  111  The words \fBibase\fR, \fBobase\fR (limited to \fBBC_BASE_MAX\fR), and
 120  112  \fBscale\fR (limited to \fBBC_SCALE_MAX\fR).
 121  113  .in -2
 122  114  .SS "Other Operands"
 123      -.sp
 124      -.LP
 125  115  Arbitrarily long numbers with optional sign and decimal point. Strings of fewer
 126  116  than \fBBC_STRING_MAX\fR characters, between double quotes ("). \fB(\fR \fIE\fR
 127  117  \fB)\fR
 128  118  .sp
 129  119  .ne 2
 130  120  .na
 131  121  \fB\fBsqrt ( \fR\fIE\fR\fB )\fR\fR
 132  122  .ad
 133  123  .RS 21n
 134  124  Square root
↓ open down ↓ 20 lines elided ↑ open up ↑
 155  145  .sp
 156  146  .ne 2
 157  147  .na
 158  148  \fB\fIL \fR\fB( \fR\fIE\fR , ... , \fIE\fR\fB )\fR\fR
 159  149  .ad
 160  150  .RS 21n
 161  151  
 162  152  .RE
 163  153  
 164  154  .SS "Operators"
 165      -.sp
 166  155  .ne 2
 167  156  .na
 168  157  \fB\fB+   \(mi   *   /   %   ^\fR\fR
 169  158  .ad
 170  159  .sp .6
 171  160  .RS 4n
 172  161  (\fB%\fR is remainder; \fB^\fR is power)
 173  162  .RE
 174  163  
 175  164  .sp
↓ open down ↓ 20 lines elided ↑ open up ↑
 196  185  .ne 2
 197  186  .na
 198  187  \fB\fB=   =+   =\(mi   =*   =/   =%   =^\fR\fR
 199  188  .ad
 200  189  .sp .6
 201  190  .RS 4n
 202  191  
 203  192  .RE
 204  193  
 205  194  .SS "Statements"
 206      -.br
 207  195  .in +2
 208  196  \fIE\fR
 209  197  .in -2
 210  198  .br
 211  199  .in +2
 212  200  \fB{\fR \fIS\fR \fB;\fR.\|.\|. \fB;\fR \fIS\fR \fB}\fR
 213  201  .in -2
 214  202  .br
 215  203  .in +2
 216  204  \fBif (\fR \fIE\fR \fB)\fR \fIS\fR
↓ open down ↓ 15 lines elided ↑ open up ↑
 232  220  \fBbreak\fR
 233  221  .in -2
 234  222  .br
 235  223  .in +2
 236  224  \fBquit\fR
 237  225  .in -2
 238  226  .sp
 239  227  .LP
 240  228  \&.string
 241  229  .SS "Function Definitions"
 242      -.br
 243  230  .in +2
 244  231  \fBdefine\fR \fIL\fR \fB(\fR \fIL\fR \fB,\fR.\|.\|.\|\fB,\fR \fIL\fR \fB) {\fR
 245  232  .in -2
 246  233  .br
 247  234  .in +2
 248  235  \fBauto\fR \fIL\fR \fB,\fR.\|.\|.\|\fB,\fR \fIL\fR
 249  236  .in -2
 250  237  .br
 251  238  .in +2
 252  239  \fIS\fR \fB;\fR.\|.\|.\| \fIS\fR
 253  240  .in -2
 254  241  .br
 255  242  .in +2
 256  243  \fBreturn (\fR \fIE\fR \fB)\fR
 257  244  .in -2
 258  245  .br
 259  246  .in +2
 260  247  \fB}\fR
 261  248  .in -2
 262  249  .SS "Functions in \fB-l\fR Math Library"
 263      -.sp
 264  250  .ne 2
 265  251  .na
 266  252  \fB\fBs(\fR\fIx\fR\fB)\fR\fR
 267  253  .ad
 268  254  .RS 10n
 269  255  sine
 270  256  .RE
 271  257  
 272  258  .sp
 273  259  .ne 2
↓ open down ↓ 51 lines elided ↑ open up ↑
 325  311  retained on arithmetic operations in the manner of \fBdc\fR. Assignments to
 326  312  \fBibase\fR or \fBobase\fR set the input and output number radix respectively.
 327  313  .sp
 328  314  .LP
 329  315  The same letter may be used as an array, a function, and a simple variable
 330  316  simultaneously. All variables are global to the program. \fBauto\fR variables
 331  317  are stacked during function calls. When using arrays as function arguments or
 332  318  defining them as automatic variables, empty square brackets must follow the
 333  319  array name.
 334  320  .SH OPTIONS
 335      -.sp
 336      -.LP
 337  321  The following operands are supported:
 338  322  .sp
 339  323  .ne 2
 340  324  .na
 341  325  \fB\fB-c\fR\fR
 342  326  .ad
 343  327  .RS 6n
 344  328  Compiles only. The output is \fBdc\fR commands that are sent to the standard
 345  329  output.
 346  330  .RE
 347  331  
 348  332  .SS "/usr/bin/bc"
 349      -.sp
 350  333  .ne 2
 351  334  .na
 352  335  \fB\fB-l\fR\fR
 353  336  .ad
 354  337  .RS 6n
 355  338  Defines the math functions and initializes \fBscale\fR to \fB20\fR, instead of
 356  339  the default zero.
 357  340  .RE
 358  341  
 359  342  .SS "/usr/xpg6/bin/bc"
 360      -.sp
 361  343  .ne 2
 362  344  .na
 363  345  \fB\fB-l\fR\fR
 364  346  .ad
 365  347  .RS 6n
 366  348  Defines the math functions and initializes \fBscale\fR to \fB20\fR, instead of
 367  349  the default zero. All math results have the scale of \fB20\fR.
 368  350  .RE
 369  351  
 370  352  .SH OPERANDS
 371      -.sp
 372      -.LP
 373  353  The following operands are supported:
 374  354  .sp
 375  355  .ne 2
 376  356  .na
 377  357  \fB\fIfile\fR\fR
 378  358  .ad
 379  359  .RS 8n
 380  360  A pathname of a text file containing \fBbc\fR program statements. After all
 381  361  cases of \fIfile\fR have been read, \fBbc\fR reads the standard input.
 382  362  .RE
 383  363  
 384  364  .SH EXAMPLES
 385      -.LP
 386  365  \fBExample 1 \fRSetting the precision of a variable
 387  366  .sp
 388  367  .LP
 389  368  In the shell, the following assigns an approximation of the first ten digits of
 390  369  \fBn\fR to the variable \fIx\fR:
 391  370  
 392  371  .sp
 393  372  .in +2
 394  373  .nf
 395  374  \fBx=$(printf "%s\en" 'scale = 10; 104348/33215' | bc)\fR
↓ open down ↓ 49 lines elided ↑ open up ↑
 445  424  
 446  425  .sp
 447  426  .in +2
 448  427  .nf
 449  428  \fBfor (i = 1; i <= 10; ++i) {         e(i) }\fR
 450  429  .fi
 451  430  .in -2
 452  431  .sp
 453  432  
 454  433  .SH ENVIRONMENT VARIABLES
 455      -.sp
 456      -.LP
 457  434  See \fBenviron\fR(5) for descriptions of the following environment variables
 458  435  that affect the execution of \fBbc\fR: \fBLANG\fR, \fBLC_ALL\fR,
 459  436  \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
 460  437  .SH EXIT STATUS
 461      -.sp
 462      -.LP
 463  438  The following exit values are returned:
 464  439  .sp
 465  440  .ne 2
 466  441  .na
 467  442  \fB\fB0\fR\fR
 468  443  .ad
 469  444  .RS 15n
 470  445  All input files were processed successfully.
 471  446  .RE
 472  447  
 473  448  .sp
 474  449  .ne 2
 475  450  .na
 476  451  \fB\fBunspecified\fR\fR
 477  452  .ad
 478  453  .RS 15n
 479  454  An error occurred.
 480  455  .RE
 481  456  
 482  457  .SH FILES
 483      -.sp
 484  458  .ne 2
 485  459  .na
 486  460  \fB\fB/usr/lib/lib.b\fR\fR
 487  461  .ad
 488  462  .RS 25n
 489  463  mathematical library
 490  464  .RE
 491  465  
 492  466  .sp
 493  467  .ne 2
 494  468  .na
 495  469  \fB\fB/usr/include/limits.h\fR\fR
 496  470  .ad
 497  471  .RS 25n
 498  472  to define BC_ parameters
 499  473  .RE
 500  474  
 501  475  .SH ATTRIBUTES
 502      -.sp
 503      -.LP
 504  476  See \fBattributes\fR(5) for descriptions of the following attributes:
 505  477  .sp
 506  478  
 507  479  .sp
 508  480  .TS
 509  481  box;
 510  482  c | c
 511  483  l | l .
 512  484  ATTRIBUTE TYPE  ATTRIBUTE VALUE
 513  485  _
 514  486  Interface Stability     Standard
 515  487  .TE
 516  488  
 517  489  .SH SEE ALSO
 518      -.sp
 519      -.LP
 520  490  \fBdc\fR(1), \fBawk\fR(1), \fBattributes\fR(5), \fBenviron\fR(5),
 521  491  \fBstandards\fR(5)
 522  492  .SH NOTES
 523      -.sp
 524      -.LP
 525  493  The \fBbc\fR command does not recognize the logical operators \fB&&\fR and
 526  494  \fB|\||\fR.
 527  495  .sp
 528  496  .LP
 529  497  The \fBfor\fR statement must have all three expressions (\fIE\fR's).
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX