\HeaderA{Arithmetic}{Arithmetic Operators}{Arithmetic}
\aliasA{*}{Arithmetic}{*}
\aliasA{+}{Arithmetic}{+}
\aliasA{-}{Arithmetic}{.Rdash.}
\aliasA{/}{Arithmetic}{/}
\aliasA{\%/\%}{Arithmetic}{.Rpcent./.Rpcent.}
\aliasA{\%\%}{Arithmetic}{.Rpcent..Rpcent.}
\aliasA{\textasciicircum{}}{Arithmetic}{\textasciicircum.Rlbrace..Rrbrace.}
\keyword{arith}{Arithmetic}
\begin{Description}\relax
These binary operators perform arithmetic on numeric or complex vectors
(or objects which can be coerced to them).
\end{Description}
\begin{Usage}
\begin{verbatim}
x + y
x - y
x * y
x / y
x ^ y
x %% y
x %/% y
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x, y}] numeric or complex vectors or objects which can be
coerced to such, or other objects for which methods have been written.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The binary arithmetic operators are generic functions: methods can be
written for them individually or via the \code{\LinkA{Ops}{Ops}}) group generic
function.

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 \textasciicircum{} y} and \code{y \textasciicircum{} 0} are \code{1}, \emph{always}.
\code{x \textasciicircum{} y} should also give the proper \dQuote{limit} result when
either argument is infinite (i.e., \code{+- \LinkA{Inf}{Inf}}).

Objects such as arrays or time-series can be operated on this
way provided they are conformable.

For real arguments, \code{\%\%} can be subject to catastrophic loss of
accuracy if \code{x} is much larger than \code{y}, and a warning is
given if this is detected.
\end{Details}
\begin{Value}
They return numeric vectors containing the result of the element
by element operations.  The elements of shorter vectors are recycled
as necessary (with a \code{\LinkA{warning}{warning}} when they are recycled only
\emph{fractionally}).  The operators are \code{+} for addition,
\code{-} for subtraction, \code{*} for multiplication, \code{/} for
division and \code{\textasciicircum{}} for exponentiation.

\code{\%\%} indicates \code{x mod y} and \code{\%/\%} indicates
integer division.  It is guaranteed that \code{x == (x \%\% y) + y * ( x
    \%/\% y )} (up to rounding error) unless \code{y == 0}
where the result is \code{\LinkA{NA}{NA}} or \code{\LinkA{NaN}{NaN}} (depending
on the \code{\LinkA{typeof}{typeof}} of the arguments).
\end{Value}
\begin{References}\relax
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
\emph{The New S Language}.
Wadsworth \& Brooks/Cole.
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{sqrt}{sqrt}} for miscellaneous and \code{\LinkA{Special}{Special}} for special
mathematical functions.

\code{\LinkA{Syntax}{Syntax}} for operator precedence.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
x <- -1:12
x + 1
2 * x + 3
x %% 2 #-- is periodic
x %/% 5
\end{ExampleCode}
\end{Examples}

