Rev 27625 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{Arithmetic}\title{Arithmetic Operators}\usage{x + yx - yx * yx / yx ^ yx \%\% yx \%/\% y}\alias{+}\alias{-}\alias{*}\alias{/}\alias{^}\alias{\%\%}\alias{\%/\%}\alias{Arithmetic}\description{These binary operators perform arithmetic on numeric or complex vectors(or objects which can be coerced to them).}\arguments{\item{x, y}{numeric or complex vectors or objects which can becoerced to such, or other objects for which methods have been written.}}\value{They return numeric vectors containing the result of the elementby element operations. The elements of shorter vectors are recycledas necessary (with a \code{\link{warning}} when they are recycled only\emph{fractionally}). The operators are \code{+} for addition,\code{-} for subtraction, \code{*} for multiplication, \code{/} fordivision and \code{^} for exponentiation.\code{\%\%} indicates \code{x mod y} and \code{\%/\%} indicatesinteger division. It is guaranteed that \code{x == (x \%\% y) + y * ( x\%/\% y )} unless \code{y == 0} where the result is \code{\link{NA}} or\code{\link{NaN}} (depending on the \code{\link{typeof}} of thearguments).}\details{The binary arithmetic operators are generic functions: methods can bewritten for them individually or via the \code{\link{Ops}}) group genericfunction.If applied to arrays the result will be an array if this is sensible(for example it will not if the recycling rule has been invoked).Logical vectors will be coerced to numeric vectors, \code{FALSE}having value 0 and \code{TRUE} having value one.\code{1 ^ y} and \code{y ^ 0} are \code{1}, \emph{always}.\code{x ^ y} should also give the proper \dQuote{limit} result wheneither argument is infinite (i.e., \code{+- \link{Inf}}).Objects such as arrays or time-series can be operated on thisway provided they are conformable.}\references{Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)\emph{The New S Language}.Wadsworth \& Brooks/Cole.}\seealso{\code{\link{sqrt}} for miscellaneous and \code{\link{Special}} for specialmathematical functions.\code{\link{Syntax}} for operator precedence.}\examples{x <- -1:12x + 12 * x + 3x \%\% 2 #-- is periodicx \%/\% 5}\keyword{arith}