1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
\subsection{precision}
\label{labprecision}
\noindent Name: \textbf{precision}\\
\phantom{aaa}returns the precision necessary to represent a number.\\[0.2cm]
\noindent Library name:\\
\verb| sollya_obj_t sollya_lib_precision(sollya_obj_t)|\\[0.2cm]
\noindent Usage:
\begin{center}
\textbf{precision}(\emph{x}) : \textsf{constant} $\rightarrow$ \textsf{integer}\\
\end{center}
Parameters:
\begin{itemize}
\item \emph{x} is a dyadic number.
\end{itemize}
\noindent Description: \begin{itemize}
\item \textbf{precision}(x) is by definition $\vert x \vert$ if x equals 0, NaN, or Inf.
\item If \emph{x} is not zero, it can be uniquely written as $x = m \cdot 2^e$ where
$m$ is an odd integer and $e$ is an integer. \textbf{precision}(x) returns the number
of bits necessary to write $m$ in binary (i.e. $1+ \lfloor \log_2(m) \rfloor$).
\end{itemize}
\noindent Example 1:
\begin{center}\begin{minipage}{15cm}\begin{Verbatim}[frame=single]
> a=round(Pi,20,RN);
> precision(a);
19
> m=mantissa(a);
> 1+floor(log2(m));
19
\end{Verbatim}
\end{minipage}\end{center}
\noindent Example 2:
\begin{center}\begin{minipage}{15cm}\begin{Verbatim}[frame=single]
> a=255;
> precision(a);
8
> m=mantissa(a);
> 1+floor(log2(m));
8
\end{Verbatim}
\end{minipage}\end{center}
\noindent Example 3:
\begin{center}\begin{minipage}{15cm}\begin{Verbatim}[frame=single]
> a=256;
> precision(a);
1
> m=mantissa(a);
> 1+floor(log2(m));
1
\end{Verbatim}
\end{minipage}\end{center}
See also: \textbf{mantissa} (\ref{labmantissa}), \textbf{exponent} (\ref{labexponent}), \textbf{round} (\ref{labround})
|