[BACK]Return to bc.1 CVS log [TXT][DIR] Up to [local] / src / usr.bin / bc

Diff for /src/usr.bin/bc/bc.1 between version 1.13 and 1.14

version 1.13, 2003/11/12 19:35:54 version 1.14, 2003/11/17 11:21:00
Line 113 
Line 113 
 is ignored within numbers.  is ignored within numbers.
 .Pp  .Pp
 Operators  Operators
 .Bd -unfilled -offset indent -compact  
 +  \-  *  /  %  ^ (`%' is remainder; `^' is power)  
 ++   \-\-         (prefix and postfix; apply to names)  
 ==  <=  >=  !=  <  >  
 =  +=  \-=  *=  /=  %=  ^=  
 .Ed  
 .Pp  .Pp
   The following arithmetic and logical operators can be used.
   The semantics of the operators is the same as in the C language.
   They are listed in order of decreasing precedence.
   Operators in the same group have the same precedence.
   .Bl -column -offset indent "= += \-= *= /= %= ^=" "Associativity" \
   "multiply, divide, modulus"
   .It Sy "Operator" Ta Sy "Associativity" Ta Sy "Description"
   .It "++ \-\-" Ta "none" Ta "increment, decrement"
   .It "\-" Ta "none" Ta "unary minus"
   .It "^" Ta "right" Ta "power"
   .It "* / %" Ta "left" Ta "multiply, divide, modulus"
   .It "+ \-" Ta "left" Ta "plus, minus"
   .It "= += -= *= /= %= ^=" Ta "right" Ta "assignment"
   .It "== <= >= != < >" Ta "none" Ta "relational"
   .It "!" Ta "none" Ta "boolean not"
   .It "&&" Ta "left" Ta "boolean and"
   .It "||" Ta "left" Ta "boolean or"
   .El
   .Pp
   Note the following:
   .Bl -bullet -offset indent
   .It
   The relational operators may appear in any expression.
   The
   .St -p1003.2
   standard only allows them in the conditional expression of an
   .Sq if ,
   .Sq while
   or
   .Sq for
   statement.
   .It
   The relational operators have a lower precedence than the assignment
   operators.
   This has the consequence that the expression
   .Sy a = b < c
   is interpreted as
   .Sy (a = b) < c ,
   which is probably not what the programmer intended.
   .It
   In contrast with the C language, the relational operators all have
   the same precedence, and are non-associative.
   The expression
   .Sy a < b < c
   will produce a syntax error.
   .It
   The boolean operators (!, && and ||) are non-portable extensions.
   .It
   The boolean not
   (!) operator has much lower precedence than the same operator in the
   C language.
   This has the consquence that the expression
   .Sy !a < b
   is interpeted as
   .Sy !(a < b) .
   Prudent programmers use parentheses when writing expressions involving
   boolean operators.
   .El
   .Pp
 Statements  Statements
 .Bd -unfilled -offset indent -compact  .Bd -unfilled -offset indent -compact
 E  E
Line 272 
Line 325 
 .Sh SEE ALSO  .Sh SEE ALSO
 .Xr dc 1  .Xr dc 1
 .Rs  .Rs
 .%B USD  .%B USD:06
 .%V 06  
 .%A L. L. Cherry  .%A L. L. Cherry
 .%A R. Morris  .%A R. Morris
 .%T "BC \- An arbitrary precision desk-calculator language"  .%T "BC \- An arbitrary precision desk-calculator language"
Line 305 
Line 357 
 utility was written by  utility was written by
 .An Otto Moerbeek .  .An Otto Moerbeek .
 .Sh BUGS  .Sh BUGS
 No  
 .Sq && ,  
 .Sq \(or\(or ,  
 or  
 .Sq \&!  
 operators.  
 .Pp  
 .Ql Quit  .Ql Quit
 is interpreted when read, not when executed.  is interpreted when read, not when executed.
 .Pp  .Pp

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14