\subsection{rationalmode}
\label{labrationalmode}
\noindent Name: \textbf{rationalmode}\\
\phantom{aaa}global variable controlling if rational arithmetic is used or not.\\[0.2cm]
\noindent Library names:\\
\verb|   void sollya_lib_set_rationalmode_and_print(sollya_obj_t)|\\
\verb|   void sollya_lib_set_rationalmode(sollya_obj_t)|\\
\verb|   sollya_obj_t sollya_lib_get_rationalmode()|\\[0.2cm]
\noindent Usage: 
\begin{center}
\textbf{rationalmode} = \emph{activation value} : \textsf{on$|$off} $\rightarrow$ \textsf{void}\\
\textbf{rationalmode} = \emph{activation value} ! : \textsf{on$|$off} $\rightarrow$ \textsf{void}\\
\textbf{rationalmode} : \textsf{on$|$off}\\
\end{center}
Parameters: 
\begin{itemize}
\item \emph{activation value} controls if rational arithmetic should be used or not
\end{itemize}
\noindent Description: \begin{itemize}

\item \textbf{rationalmode} is a global variable. When its value is \textbf{off}, which is the
   default, \sollya will not use rational arithmetic to simplify expressions. All
   computations, including the evaluation of constant expressions given on the
   \sollya prompt, will be performed using floating-point and interval
   arithmetic.
   Constant expressions will be approximated by floating-point numbers, which
   are in most cases faithful roundings of the expressions, when shown at the
   prompt.

\item When the value of the global variable \textbf{rationalmode} is \textbf{on}, \sollya will use
   rational arithmetic when simplifying expressions. Constant expressions, given
   at the \sollya prompt, will be simplified to rational numbers and displayed
   as such when they are in the set of the rational numbers. Otherwise,
   floating-point and interval arithmetic will be used to compute a
   floating-point approximation, which is in most cases a faithful rounding of
   the constant expression.

\item When a decimal value is parsed, the behavior of \sollya is different
   depending on the value of the global variable \textbf{rationalmode}. If it is \textbf{off}, the
   value gets rounded as a floating-point at precision \textbf{prec}. But if \textbf{rationalmode}
   is set to \textbf{on}, the decimal value is interpreted exactly and converted as a
   rational number of the form $M/10^N$ where $M$ and $N$ are integers. Accordingly,
   when \textbf{rationalmode} is set to \textbf{on} and \textbf{display} is set to \textbf{decimal}, all
   floating-point values are displayed exactly: indeed, any floating-point
   number with radix 2 has a finite decimal expansion. Therefore, any rational
   number of the form $M/(2^P\cdot 5^Q)$ gets displayed as an exact decimal value
   (while other fractions get displayed as fractions).
\end{itemize}
\noindent Example 1: 
\begin{center}\begin{minipage}{15cm}\begin{Verbatim}[frame=single]
> rationalmode=off!;
> 19/17 + 3/94;
1.1495619524405506883604505632040050062578222778473
> rationalmode=on!;
> 19/17 + 3/94;
1837 / 1598
\end{Verbatim}
\end{minipage}\end{center}
\noindent Example 2: 
\begin{center}\begin{minipage}{15cm}\begin{Verbatim}[frame=single]
> rationalmode=off!;
> exp(19/17 + 3/94);
3.1568097739551413675470920894482427634032816281442
> rationalmode=on!;
> exp(19/17 + 3/94);
3.156809773955141367547092089448242763403281628144179657491921848227943094689334
55522164268460461069584760073436423014140708373509447426386032020673155784606933
59375
\end{Verbatim}
\end{minipage}\end{center}
\noindent Example 3: 
\begin{center}\begin{minipage}{15cm}\begin{Verbatim}[frame=single]
> prec = 12!;
> rationalmode=off!;
> r = 0.1;
> r == 1/10;
false
> rationalmode=on!;
> s = 0.1;
> s == 1/10;
true
> r == s;
false
> r;
0.100006103515625
> s;
0.1
\end{Verbatim}
\end{minipage}\end{center}
See also: \textbf{on} (\ref{labon}), \textbf{off} (\ref{laboff}), \textbf{numerator} (\ref{labnumerator}), \textbf{denominator} (\ref{labdenominator}), \textbf{simplify} (\ref{labsimplify}), \textbf{rationalapprox} (\ref{labrationalapprox}), \textbf{autosimplify} (\ref{labautosimplify})
