Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Henrik Tidefelt <henrikt@wolfram.com>
  • Loading branch information
HansOlsson and henrikt-ma committed Jan 2, 2023
1 parent ebb39e4 commit 7855a3f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions chapters/arrays.tex
Expand Up @@ -1268,18 +1268,18 @@ \subsection{Element-wise Division}\label{array-element-wise-division}\label{elem

\subsection{Element-wise Exponentiation}\label{element-wise-exponentiation}

Exponentiation \lstinline!a ^ b! always returns a \lstinline!Real! scalar value, and it is required that \lstinline!a! and \lstinline!b! are scalar \lstinline!Real! or \lstinline!Integer! values.
The result should correspond to mathematical exponentiation (ideally the correctly rounded result based on the inputs) with the following special cases:
Exponentiation \lstinline!a ^ b! always returns a \lstinline!Real! scalar value, and it is required that \lstinline!a! and \lstinline!b! are scalar \lstinline!Real! or \lstinline!Integer! expressions.
The result should correspond to mathematical exponentiation with the following special cases:
\begin{itemize}
\item If $\text{\lstinline!a!} = 0.0$ and $\text{\lstinline!b!} = 0$ for an \lstinline!Integer! expression \lstinline!b! the result is $1.0$.
\item For any value of \lstinline!a! (including $0.0$) and an \lstinline!Integer! $\text{\lstinline!b!} = 0$, the result is $1.0$.
\item If $\text{\lstinline!a!} < 0$ and \lstinline!b! is an \lstinline!Integer!, the result is defined as $\pm |a|^b$, with sign depending on whether \lstinline!b! is even (positive) or odd (negative).
\item If $\text{\lstinline!a!} < 0$ and \lstinline!b! is a \lstinline!Real! having a non-zero integer value, the result is defined as $\pm |a|^b$, with sign depending on whether \lstinline!b! is even (positive) or odd (negative). This case is deprecated, and tools may warn once during a simulation if this occurs.
\item A deprecated semantics is to treat $\text{\lstinline!a!} < 0$ and a \lstinline!Real! \lstinline!b! having a non-zero integer value as if \lstinline!b! were an \lstinline!Integer!.
\item Consequences of other exceptional situations, such as ($\text{\lstinline!a!} = 0.0$ and $\text{\lstinline!b!} = 0.0$ for a \lstinline!Real b!, $\text{\lstinline!a!} = 0.0$ and $\text{\lstinline!b!} < 0$, or $\text{\lstinline!a!} < 0$ and \lstinline!b! does not have an integer value) or overflow are undefined.
\end{itemize}

\begin{nonnormative}
Except for defining the special case of $0.0^0$ it corresponds to \lstinline[language=C]!pow(double a, double b)! in the ANSI~C library.
The result is always \lstinline!Real! due to the potential for integer overflow and negative exponents.
The result is always \lstinline!Real! as negative exponents can give non-integer results also when both operands are \lstinline!Integer!.
The special treatment of \lstinline!Integer! exponents makes it possible to use $x^n$ in a power series.
\end{nonnormative}

Expand Down

0 comments on commit 7855a3f

Please sign in to comment.