\subsection{roundcoefficients}
\label{labroundcoefficients}
\noindent Name: \textbf{roundcoefficients}\\
\phantom{aaa}rounds the coefficients of a polynomial to classical formats.\\[0.2cm]
\noindent Library name:\\
\verb|   sollya_obj_t sollya_lib_roundcoefficients(sollya_obj_t, sollya_obj_t)|\\[0.2cm]
\noindent Usage: 
\begin{center}
\textbf{roundcoefficients}(\emph{p},\emph{L}) : (\textsf{function}, \textsf{list}) $\rightarrow$ \textsf{function}\\
\end{center}
Parameters: 
\begin{itemize}
\item \emph{p} is a function. Usually a polynomial.
\item \emph{L} is a list of formats.
\end{itemize}
\noindent Description: \begin{itemize}

\item If \emph{p} is a polynomial and \emph{L} a list of floating-point formats, 
   \textbf{roundcoefficients}(\emph{p},\emph{L}) rounds each coefficient of \emph{p} to the corresponding format
   in \emph{L}.

\item If \emph{p} is not a polynomial, \textbf{roundcoefficients} does not do anything.

\item If \emph{L} contains other elements than \textbf{HP}, \textbf{halfprecision}, \textbf{SG}, \textbf{single}, \textbf{D}, \textbf{double}, 
   \textbf{DE}, \textbf{doubleextended}, \textbf{DD}, \textbf{doubledouble}, \textbf{QD}, \textbf{quad}, \textbf{TD} and \textbf{tripledouble},
   an error occurs.

\item The coefficients in \emph{p} corresponding to $X^i$ is rounded to the 
   format L[i]. If \emph{L} does not contain enough elements
   (e.g. if \textbf{length}(L) $<$ \textbf{degree}(p)+1), a warning is displayed. However, the
   coefficients corresponding to an element of \emph{L} are rounded. The trailing 
   coefficients (that do not have a corresponding element in \emph{L}) are kept with
   their own precision.
   If \emph{L} contains too much elements, the trailing useless elements are ignored.
   In particular \emph{L} may be end-elliptic in which case \textbf{roundcoefficients} has the 
   natural behavior.
\end{itemize}
\noindent Example 1: 
\begin{center}\begin{minipage}{15cm}\begin{Verbatim}[frame=single]
> p=exp(1) + x*(exp(2) + x*exp(3));
> display=binary!;
> roundcoefficients(p,[|DD,D,D|]);
1.010110111111000010101000101100010100010101110110100101010011010101011111101110
001010110001000000010011101_2 * 2^(1) + x * (1.110110001110011001001011100011010
100110111011010111_2 * 2^(2) + x * (1.010000010101111001011011111101101111101100
010000011_2 * 2^(4)))
> roundcoefficients(p,[|DD,D...|]);
1.010110111111000010101000101100010100010101110110100101010011010101011111101110
001010110001000000010011101_2 * 2^(1) + x * (1.110110001110011001001011100011010
100110111011010111_2 * 2^(2) + x * (1.010000010101111001011011111101101111101100
010000011_2 * 2^(4)))
\end{Verbatim}
\end{minipage}\end{center}
\noindent Example 2: 
\begin{center}\begin{minipage}{15cm}\begin{Verbatim}[frame=single]
> f=sin(exp(1)*x);
> display=binary!;
> f;
sin(x * (1.010110111111000010101000101100010100010101110110100101010011010101011
11110111000101011000100000001001110011110100111100111100011101100010111001110001
01100000111101_2 * 2^(1)))
> roundcoefficients(f,[|D...|]);
sin(x * (1.010110111111000010101000101100010100010101110110100101010011010101011
11110111000101011000100000001001110011110100111100111100011101100010111001110001
01100000111101_2 * 2^(1)))
\end{Verbatim}
\end{minipage}\end{center}
\noindent Example 3: 
\begin{center}\begin{minipage}{15cm}\begin{Verbatim}[frame=single]
> p=exp(1) + x*(exp(2) + x*exp(3));
> verbosity=1!;
> display=binary!;
> roundcoefficients(p,[|DD,D|]);
Warning: the number of the given formats does not correspond to the degree of th
e given polynomial.
Warning: the 0th coefficient of the given polynomial does not evaluate to a floa
ting-point constant without any rounding.
Will evaluate the coefficient in the current precision in floating-point before 
rounding to the target format.
Warning: the 1th coefficient of the given polynomial does not evaluate to a floa
ting-point constant without any rounding.
Will evaluate the coefficient in the current precision in floating-point before 
rounding to the target format.
Warning: rounding may have happened.
1.010110111111000010101000101100010100010101110110100101010011010101011111101110
001010110001000000010011101_2 * 2^(1) + x * (1.110110001110011001001011100011010
100110111011010111_2 * 2^(2) + x * (1.010000010101111001011011111101101111101100
01000001011111001011010100101111011111110001010011011101000100110000111010001110
010000010110000101100000111001011100101001_2 * 2^(4)))
\end{Verbatim}
\end{minipage}\end{center}
See also: \textbf{halfprecision} (\ref{labhalfprecision}), \textbf{single} (\ref{labsingle}), \textbf{double} (\ref{labdouble}), \textbf{doubleextended} (\ref{labdoubleextended}), \textbf{doubledouble} (\ref{labdoubledouble}), \textbf{quad} (\ref{labquad}), \textbf{tripledouble} (\ref{labtripledouble}), \textbf{fpminimax} (\ref{labfpminimax}), \textbf{remez} (\ref{labremez}), \textbf{implementpoly} (\ref{labimplementpoly}), \textbf{subpoly} (\ref{labsubpoly})
