%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%%  bigfloat.tex        LiDIA documentation
%%
%%  This file contains the documentation of the class bigfloat
%%  
%%  Copyright (c) 1995 by the LiDIA Group
%%
%%  Authors: Thomas Papanikolaou
%%  

\markright{\BF{bigfloat}}
\begin{lidia_man}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\NAME
\BF{bigfloat} \DOTFILL   multiprecision floating point arithmetic
\label{bigfloat_class}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\ABSTRACT
\BF{bigfloat} is a class for doing multiprecision arithmetic over
\MATH{\R}. It supports for example arithmetic operations, shift
operations,  comparisons,  the  square root  function, the
exponential function, the logarithmical function,  (inverse)
trigonometric functions etc.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\DESCRIPTION
Before declaring a \BF{bigfloat} it is possible to set the
decimal precision \MATH{p} by

\begin{center}
\TT{bigfloat::set\_precision(p)}
\end{center}

Then the \BF{base digit} precision (see class \BF{bigint}, page
\pageref{bigint_class}) is

\begin{center}
\TT{\MATH{t = \LCEIL(p * log(10) / log(base))\RCEIL + 3}},   
\end{center}

where \MATH{base} is the value of the \BF{bigint base}. If the
precision has not been set, a default precision
of \MATH{t = 5} \BF{bigint} base digits is used. If the decimal
precision is set to \MATH{p}  then a \BF{bigfloat} is a
pair \MATH{(m, e)}, where \MATH{m} is a \BF{bigint}
with \MATH{|m| < base^p} and \MATH{e} is a machine integer. It
represents the number

\begin{center}
\MATH{0.m * 2^e}
\end{center}

The number \MATH{m} is called the \BF{mantissa} and the
number \MATH{e} is called the \BF{exponent}.

A complete description of the floating point representation and
the algorithms for the basic operations (\TT{+, -, *, /})
of \BF{bigfloat} can be found in the book of D. Knuth
(see \cite{knuth}). The more sophisticated algorithms which are
used in \BF{bigfloat} are implemented according to R.P.~Brent
(see \cite{brentj},  \cite{brente}, \cite{brentm})  and  J.M.~and
P.B.~Borwein (see \cite{borwein}). There one can also find the
time- and error-bound analysis of these algorithms.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\CONS
\fcode{ct}{bigfloat}{}
{ 
initializes with 0.}


\fcode{ct}{bigfloat}{int}
{
initializes with int.}


\fcode{ct}{bigfloat}{long}
{
initializes with long.}


\fcode{ct}{bigfloat}{unsigned long}
{
initializes with unsigned long.}


\fcode{ct}{bigfloat}{double}
{
initializes with double.}


\fcode{ct}{bigfloat}{const bigint \&}
{
initializes with bigint.}


\fcode{ct}{bigfloat}{const bigint \&\k const bigint \&}
{
This constructor initializes a \BF{bigfloat} with the result of the floating point division
of two \BF{bigint}s. Rounding is performed according to the current
rounding mode. For this see the function \TT{mode(rounding mode(rounding mode))}.}


\fcode{ct}{bigfloat}{const bigrational \& \MATH{b}}
{
This constructor initializes a \BF{bigfloat} with the result of the floating point division
of the numerator and the denominator of \MATH{b}. Rounding is performed according to the current
rounding mode. For this see the function \TT{mode(rounding mode(rounding mode))}.}


\fcode{ct}{bigfloat}{const bigfloat \&}
{
initializes with a bigfloat.}


\fcode{dt}{\SIM bigfloat}{}
{
deletes the bigfloat object.}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\INIT
\label{bigfloat_init}
\fcode{static void}{set\_precision}{long p}
{
sets the global decimal precision to \MATH{p} decimal places.
Then the base digit precision
is \MATH{t = \LCEIL(p*log(10)/log(base))\RCEIL + 3},
where \MATH{base} is the \BF{bigint} base. Thus we
have \MATH{|m| \LE\ base ^ {p}} for all \BF{bigfloat}s \MATH{(m, e)}, 
i.e. \MATH{m} is a \BF{bigint} of length at most \MATH{t}.
Whenever necessary, internal computations are done with a higher
precision.}


\fcode{static long}{get\_precision}{}
{
returns the current decimal precision.}


\fcode{static void}{mode}{long m}
{
sets the rounding mode for the normalization routine according to
the IEEE standard (see \cite{IEE87}). The following modes are
available:

\TT{MP\_TRUNC}: round to zero.

\TT{MP\_RND}: round to nearest. If there are two possibilities to
do this, round to even.

\TT{MP\_RND\_UP} round to \MATH{+\INFTY}.

\TT{MP\_RND\_DOWN} round to \MATH{-\INFTY}.}



\fcode{static int}{get\_mode}{}
{
return the current rounding mode.}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\TYPE
Before  assigning  a \BF{bigfloat}  to a machine type (e.g.~int)
it is often useful to perform  a  test  which checks whether the
assignment can be done without overflow. The following  functions
return \TRUE\ if  the  assignment would be successful, \FALSE\ 
otherwise. No rounding is done.


\fcode{bool}{is\_char}{const bigfloat \&}{}
\fcode{bool}{is\_uchar}{const bigfloat \&}{}
\fcode{bool}{is\_short}{const bigfloat \&}{}
\fcode{bool}{is\_ushort}{const bigfloat \&}{}
\fcode{bool}{is\_int}{const bigfloat \&}{}
\fcode{bool}{is\_uint}{const bigfloat \&}{}
\fcode{bool}{is\_long}{const bigfloat \&}{}
\fcode{bool}{is\_ulong}{const bigfloat \&}{}
\fcode{bool}{is\_double}{const bigfloat \&}{}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\ASGN
Let \MATH{a} be of type \BF{bigfloat}. The operator \TT{=} is
overloaded. For  efficiency reasons the following functions are
also implemented:


\fcode{void}{a.assign\_zero}{}
{
\MATH{a = 0}.}


\fcode{void}{a.assign\_one}{}
{
\MATH{a = 1}.}


\fcode{void}{a.assign}{int i}
{
\MATH{a = i}.}


\fcode{void}{a.assign}{long l}
{
\MATH{a = l}.}


\fcode{void}{a.assign}{unsigned long ul}
{
\MATH{a = ul}.}


\fcode{void}{a.assign}{double d}
{
\MATH{a = d}.}


\fcode{void}{a.assign}{const bigint \& I}
{
\MATH{a = I}.}


\fcode{void}{a.assign}{const bigint \& I\k const bigint \& J}
{
\MATH{a = I / J} (floating point division) if \MATH{J \NEQ 0}.
Otherwise the \TT{lidia\_error\_handler} will be invoked.}


\fcode{void}{a.assign}{const bigfloat \& bf}
{
\MATH{a = bf}.}


\cfcode{void}{a.bigintify}{bigint  \& I}
{
\MATH{I = \LFLOOR a + 1/2 \RFLOOR}, i.e. I is the nearest integer
to \MATH{a}.}


\cfcode{bool}{a.doublify}{double  \& d}
{
tries to perform the assignment \MATH{d = a}. If successful,
i.e. no overflow occurs, the function returns \FALSE\ and
assigns \MATH{a} to \MATH{d}. Otherwise it returns \TRUE\ and
leaves the value of \MATH{d} unchanged.}


\cfcode{bool}{a.intify}{int  \& i}
{
tries to perform the assignment \MATH{i = a}. If successful,
i.e. no overflow occurs, the function returns \FALSE\ and
assigns \MATH{a} to \MATH{i}. Otherwise it returns \TRUE\ and
leaves the value of \MATH{i} unchanged.}


\cfcode{bool}{a.longify}{long  \& i}
{
tries to perform the assignment \MATH{i = a}. If successful,
i.e. no overflow occurs, the function returns \FALSE\ and
assigns \MATH{a} to \MATH{i}. Otherwise it returns \TRUE\ and
leaves the value of \MATH{i} unchanged.}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\ACCS
Let \MATH{a} be of type \BF{bigfloat}.


\fcode{long}{a.exponent}{}
{
returns the exponent of \MATH{a}.}


\fcode{bigint}{a.mantissa}{}
{
returns the mantissa of \MATH{a}.}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\ARTH
The following operators are overloaded and can be used in exactly
the same way as in C:

\begin{center}
\TT{(unary) -, ++, --}\\
\TT{(binary) +, -, *, /, <<, >>}\\
\TT{(binary with assignment) +=, -=, *=, /=, <<=, >>=}
\end{center}

To avoid copying all operators exist also as functions:


\fcode{void}{add}{bigfloat \& c\k const bigfloat \& a\k const bigfloat \& b}
{
\MATH{c = a + b}.}


\fcode{void}{add}{bigfloat \& c\k const bigfloat \& a\k long i}
{
\MATH{c = a + i}.}


\fcode{void}{add}{bigfloat \& c\k long i\k const bigfloat \& b}
{
\MATH{c = i + b}.}


\fcode{void}{subtract}{bigfloat \& c\k const bigfloat \& a\k const bigfloat \& b}
{
\MATH{c = a - b}.}


\fcode{void}{subtract}{bigfloat \& c\k const bigfloat \& a\k long i}
{
\MATH{c = a - i}.}


\fcode{void}{subtract}{bigfloat \& c\k long i\k const bigfloat \& b}
{
\MATH{c = i - b}.}


\fcode{void}{multiply}{bigfloat \& c\k const bigfloat \& a\k const bigfloat \& b}
{
\MATH{c = a * b}.}


\fcode{void}{multiply}{bigfloat \& c\k const bigfloat \& a\k long i}
{
\MATH{c = a * i}.}


\fcode{void}{multiply}{bigfloat \& c\k long i\k const bigfloat \& b}
{
\MATH{c = i * b}.}


\fcode{void}{divide}{bigfloat \& c\k const bigfloat \& a\k const bigfloat \& b}
{
\MATH{c = a / b}, if \MATH{b \NEQ 0}.
Otherwise the \TT{lidia\_error\_handler} will be invoked.}


\fcode{void}{divide}{bigfloat \& c\k const bigfloat \& a\k long i}
{
\MATH{c = a / i}, if \MATH{i \NEQ 0}.
Otherwise the \TT{lidia\_error\_handler} will be invoked.}


\fcode{void}{divide}{bigfloat \& c\k long i\k const bigfloat \& b}
{
\MATH{c = i / b}, if \MATH{b \NEQ 0}.
Otherwise the \TT{lidia\_error\_handler} will be invoked.}


\fcode{void}{divide}{bigfloat \& c\k long i\k long j}
{
\MATH{c = i / j} (floating point division) if \MATH{j \NEQ 0}.
Otherwise the \TT{lidia\_error\_handler} will be invoked.}


\fcode{void}{negate}{bigfloat \& a\k const bigfloat \& b}
{
\MATH{a = -b}.}


\fcode{void}{a.negate}{}
{
\MATH{a = -a}.}


\fcode{void}{a.invert}{}
{
\MATH{a = 1 / a}, if \MATH{a \NEQ 0}. Otherwise the \TT{lidia\_error\_handler} 
will be invoked.}


\fcode{void}{invert}{bigfloat \& a\k const bigfloat \& b}
{
\MATH{a = 1 / b}, if \MATH{b \NEQ 0}. Otherwise the \TT{lidia\_error\_handler} 
will be invoked.}


\fcode{bigfloat}{inverse}{const bigfloat \& a}
{
returns \MATH{1 / a}, if \MATH{a \NEQ 0}. Otherwise the 
\TT{lidia\_error\_handler} will be invoked.}


\fcode{void}{inc}{bigfloat \& a}
{
\MATH{a = a + 1}.}


\fcode{void}{dec}{bigfloat \& a}
{
\MATH{a = a - 1}.}


\fcode{void}{square}{bigfloat \& c\k const bigfloat \& a}
{
\MATH{c = \MATH{a^2}}.}


\fcode{void}{sqrt}{bigfloat \& c\k const bigfloat \& a}
{
\MATH{c = }\MATH{\SQRT{a}}, where \MATH{a >= 0}. If \MATH{a < 0},
the \TT{lidia\_error\_handler} will be invoked.}


\fcode{bigfloat}{sqrt}{const bigfloat \& a}{
returns \MATH{\SQRT{a}}, where \MATH{a >= 0}. If \MATH{a < 0},
the \TT{lidia\_error\_handler} will be invoked.}

\fcode{void}{power}{bigfloat \& c\k const bigfloat \& a\k const bigfloat \& b}
{
\MATH{c = }\MATH{a^b}, where \MATH{b > 0}. If \MATH{b \LEQ 0},
the \TT{lidia\_error\_handler} will be invoked.}


\fcode{void}{power}{bigfloat \& c\k const bigfloat \& a\k long i}
{
\MATH{c = }\MATH{a^i}.}


\fcode{bigfloat}{power}{const bigfloat \& a\k const bigfloat \& b}
{
returns \MATH{a^b}.}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\SHFT
Let \MATH{a} be of type \BF{bigfloat}. In \BF{bigfloat} shifting,
i.e. multiplication with powers of \MATH{2}, is done using
exponent manipulation.


\fcode{void}{a.multiply\_by\_2}{}
{
\MATH{a = a * 2}.}


\fcode{void}{a.divide\_by\_2}{}
{
\MATH{a = a / 2}.}


\fcode{void}{shift\_left}{bigfloat \& c\k const bigfloat \& b\k long i}
{
\MATH{c = b * \MATH{2^i}}.}


\fcode{void}{shift\_right}{bigfloat \& c\k const bigfloat \& b\k long i}
{
\MATH{c = b / \MATH{2^i}}.}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\COMP
Let \MATH{a} be of type \BF{bigfloat}.  The  binary
operators \TT{==}, \TT{!=}, \TT{>=}, \TT{<=}, \TT{>}, \TT{<} and
the unary operator \TT{!} (comparison with zero) are overloaded
and can be used in exactly the same way as in C.



\cfcode{bool}{a.is\_zero}{}
{
returns \TRUE\ if \MATH{a = 0}, \FALSE\ otherwise.}


\cfcode{bool}{a.is\_approx\_zero}{}
{
returns \TRUE\ if \MATH{|a| < base^{-t}} (see
initialization, page \pageref{bigfloat_init}), \FALSE\ otherwise.}


\cfcode{bool}{a.is\_one}{}
{
returns \TRUE\ if \MATH{a = 1}, \FALSE\ otherwise.}


\cfcode{bool}{a.is\_gt\_zero}{}
{
returns \TRUE\ if \MATH{a > 0}, \FALSE\ otherwise.}


\cfcode{bool}{a.is\_ge\_zero}{}
{
returns \TRUE\ if \MATH{a \GE\ 0}, \FALSE\ otherwise.}


\cfcode{bool}{a.is\_lt\_zero}{}
{
returns \TRUE\ if \MATH{a < 0}, \FALSE\ otherwise.}


\cfcode{bool}{a.is\_le\_zero}{}
{
returns \TRUE\ if \MATH{a \LE\ 0}, \FALSE\ otherwise.}


\cfcode{int}{a.abs\_compare}{const bigfloat \& b}
{
returns \MATH{\TT{sign}(|a| - |b|)}.}


\cfcode{int}{a.compare}{const bigfloat \& b}
{
returns \MATH{\TT{sign}(a - b)}.}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\BASIC
Let \MATH{a} be of type \BF{bigfloat}.


\cfcode{lidia\_size\_t}{a.bit\_length}{}
{
returns the length of the mantissa of \MATH{a} in binary digits.}


\cfcode{lidia\_size\_t}{a.length}{}
{
returns the length of the mantissa of \MATH{a} in \BF{bigint}
base digits.}


\cfcode{int}{a.sign}{}
{
returns 1 if \MATH{a > 0}, \MATH{0} if \MATH{a = 0} and \MATH{1}
otherwise.}

\fcode{int}{sign}{const bigfloat \& a}
{
returns 1 if \MATH{a > 0}, \MATH{0} if \MATH{a = 0} and \MATH{1}
otherwise.}


\fcode{void}{a.absolute\_value}{}
{
\MATH{a =} \MATH{|a|}.}

\fcode{bigfloat}{abs}{const bigfloat \& a}
{
returns \MATH{|a|}.}


\fcode{void}{besselj}{bigfloat \& c\k int n\k const bigfloat \& a}
{
\MATH{c = }\MATH{J_n(a)} (Bessel Function of first kind and
integer order).}

\fcode{bigfloat}{besselj}{int n\k const bigfloat \& a}
{
returns \MATH{J_n(a)} (Bessel Function of first kind and integer
order).}


\fcode{void}{ceil}{bigfloat \& c\k const bigfloat \& a}
{
\MATH{c = \LCEIL a \RCEIL}, i.e. \MATH{c} is the smallest
integer which is greater than or equal to \MATH{a}.}

\fcode{bigfloat}{ceil}{const bigfloat \& a}
{
returns \MATH{\LCEIL a \RCEIL}, i.e. \MATH{c} is the smallest
integer which is greater than or equal to \MATH{a}.}


\fcode{void}{floor}{bigfloat \& c\k const bigfloat \& a}
{
\MATH{c = \LFLOOR a \RFLOOR}, i.e. \MATH{c} is the largest
integer which is less than or equal to \MATH{a}.}

\fcode{bigfloat}{floor}{const bigfloat \& a}
{
returns \MATH{\LFLOOR a \RFLOOR}, i.e. \MATH{c} is the largest
integer which is less than or equal to \MATH{a}.}


\fcode{void}{round}{bigfloat \& c\k const bigfloat \& a}
{
\MATH{c = \LFLOOR a + 1/2 \RFLOOR}, i.e. \MATH{c} is the nearest
integer to \MATH{a}.}

\fcode{bigfloat}{round}{const bigfloat \& a}
{
returns \MATH{\LFLOOR a + 1/2 \RFLOOR}, i.e. \MATH{c} is the
nearest integer to \MATH{a}.}


\fcode{void}{truncate}{bigfloat \& c\k const bigfloat \& a}
{
\MATH{c = \TT{sign}(a) * \LFLOOR |a| \RFLOOR}.}

\fcode{bigfloat}{truncate}{const bigfloat \& a}
{
returns \MATH{\TT{sign}(a) * \LFLOOR |a| \RFLOOR}.}


\fcode{void}{exp}{bigfloat \& c\k const bigfloat \& a}
{
\MATH{c = e^a}.}

\fcode{bigfloat}{exp}{const bigfloat \& a}
{
returns \MATH{e^a}.}


\fcode{void}{log}{bigfloat \& c\k const bigfloat \& a}
{
\MATH{c = log(a)} (natural logarithm to base \MATH{e} = 2.718...),
where \MATH{a > 0}. If \MATH{a \LEQ 0}, the \TT{lidia\_error\_handler}
will be invoked.}

\fcode{bigfloat}{log}{const bigfloat \& a}
{
returns \MATH{log(a)} (natural logarithm to base \MATH{e} =
2.718...), where \MATH{a > 0}. If \MATH{a \LEQ 0} the
\TT{lidia\_error\_handler} will be invoked.}


\fcode{long}{exponent}{const bigfloat \& a}
{
returns the exponent of \MATH{a}.}


\fcode{bigint}{mantissa}{const bigfloat \& a}
{
returns the mantissa of \MATH{a}.}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\STITLE{(Inverse) Trigonometric Functions}
Note that the arguments of the trigonometrical functions are
supposed to be given as radiants.


\fcode{void}{sin}{bigfloat \& c\k const bigfloat \& a}
{
\MATH{c = \TT{sin}(a)}.}

\fcode{bigfloat}{sin}{const bigfloat \& a}
{
returns \MATH{\TT{sin}(a)}.}


\fcode{void}{cos}{bigfloat \& c\k const bigfloat \& a}
{
\MATH{c = \TT{cos}(a)}.}

\fcode{bigfloat}{cos}{const bigfloat \& a}
{
returns \MATH{\TT{cos}(a)}.}


\fcode{void}{tan}{bigfloat \& c\k const bigfloat \& a}
{
\MATH{c = \TT{tan}(a)} if \MATH{a \NEQ (2k+1)\;\pi/2}, \MATH{k \IN \Z}.
Otherwise the \TT{lidia\_error\_handler} will be invoked.}

\fcode{bigfloat}{tan}{const bigfloat \& a}
{
returns \MATH{\TT{tan}(a)} if \MATH{a \NEQ (2k+1)\;\pi/2}, \MATH{k \IN \Z}.
Otherwise the \TT{lidia\_error\_handler} will be invoked.}


\fcode{void}{cot}{bigfloat \& c\k const bigfloat \& a}
{
\MATH{c = \TT{cot}(a)} if \MATH{a \NEQ k\;\pi}, \MATH{k \IN \Z}.
Otherwise the \TT{lidia\_error\_handler} will be invoked.}

\fcode{bigfloat}{cot}{const bigfloat \& a}
{
returns \MATH{\TT{cot}(a)} if \MATH{a \NEQ k\;\pi}, \MATH{k \IN \Z}.
Otherwise the \TT{lidia\_error\_handler} will be invoked.}


\fcode{void}{asin}{bigfloat \& c\k const bigfloat \& a}
{
\MATH{c = \TT{arcsin}(a)} if \MATH{a \IN [ -1, 1 ] }.
Otherwise the \TT{lidia\_error\_handler} will be invoked.}

\fcode{bigfloat}{asin}{const bigfloat \& a}
{
returns \MATH{\TT{arcsin}(a)} if \MATH{a \IN [ -1, 1 ]}.
Otherwise the \TT{lidia\_error\_handler} will be invoked.}


\fcode{void}{acos}{bigfloat \& c\k const bigfloat \& a}
{
\MATH{c = \TT{arccos}(a)} if \MATH{a \IN [ -1, 1 ]}.
Otherwise the \TT{lidia\_error\_handler} will be invoked.}

\fcode{bigfloat}{acos}{const bigfloat \& a}
{
returns \MATH{\TT{arccos}(a)} if \MATH{a \IN [ -1, 1 ]}.
Otherwise the \TT{lidia\_error\_handler} will be invoked.}


\fcode{void}{atan}{bigfloat \& c\k const bigfloat \& a}
{
\MATH{c = \TT{arctan}(a)}.}

\fcode{bigfloat}{atan}{const bigfloat \& a}
{
returns \MATH{\TT{arctan}(a)}.}


\fcode{void}{atan2}{bigfloat \& c\k const bigfloat \& a\k const bigfloat \& b}
{
\MATH{c = \TT{arctan}(a / b)} in the range of \MATH{[ -\pi, \pi [},
i.e. atan2(a, b) calculates the argument (respectively phase) of \MATH{a, b}.}

\fcode{bigfloat}{atan2}{const bigfloat \& a\k const bigfloat \& b}
{
returns \MATH{\TT{arctan}(a / b)} in the range of \MATH{[ -\pi, \pi [},
i.e. atan2(a, b) calculates the argument (respectively phase) of \MATH{a, b}.}


\fcode{void}{acot}{bigfloat \& c\k const bigfloat \& a}
{
\MATH{c = \TT{arccot}(a)}.}

\fcode{bigfloat}{acot}{const bigfloat \& a}
{
returns \MATH{\TT{arccot}(a)}.}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\STITLE{(Inverse) Hyperbolic Trigonometric Functions}
\fcode{void}{sinh}{bigfloat \& c\k const bigfloat \& a}
{
\MATH{c = \TT{sinh}(a)}.}

\fcode{bigfloat}{sinh}{const bigfloat \& a}
{
returns \MATH{\TT{sinh}(a)}.}


\fcode{void}{cosh}{bigfloat \& c\k const bigfloat \& a}
{
\MATH{c = \TT{cosh}(a)}.}

\fcode{bigfloat}{cosh}{const bigfloat \& a}
{
returns \MATH{\TT{cosh}(a)}.}


\fcode{void}{tanh}{bigfloat \& c\k const bigfloat \& a}
{
\MATH{c = \TT{tanh}(a)}.}

\fcode{bigfloat}{tanh}{const bigfloat \& a}
{
returns \MATH{\TT{tanh}(a)}.}


\fcode{void}{coth}{bigfloat \& c\k const bigfloat \& a}
{
\MATH{c = \TT{coth}(a)}.}

\fcode{bigfloat}{coth}{const bigfloat \& a}
{
returns \MATH{\TT{coth}(a)}.}


\fcode{void}{asinh}{bigfloat \& c\k const bigfloat \& a}
{
\MATH{c = \TT{arcsinh}(a)}.}

\fcode{bigfloat}{asinh}{const bigfloat \& a}
{
returns \MATH{\TT{arcsinh}(a)}.}


\fcode{void}{acosh}{bigfloat \& c\k const bigfloat \& a}
{
\MATH{c = \TT{arccosh}(a)}, where \MATH{a \GEQ 1}.}

\fcode{bigfloat}{acosh}{const bigfloat \& a}
{
returns \MATH{\TT{arccosh}(a)}, where \MATH{a \GEQ 1}.}


\fcode{void}{atanh}{bigfloat \& c\k const bigfloat \& a}
{
\MATH{c = \TT{arctanh}(a)}, where \MATH{a \IN ]-1, 1[}.}

\fcode{bigfloat}{atanh}{const bigfloat \& a}
{
returns \MATH{\TT{arctanh}(a)}, where \MATH{a \IN ] -1, 1 [}.}


\fcode{void}{acoth}{bigfloat \& c\k const bigfloat \& a}
{
\MATH{c = \TT{arccoth}(a)}, where \MATH{a \IN \R\SETMINUS [-1, 1]}.}

\fcode{bigfloat}{acoth}{const bigfloat \& a}
{
returns \MATH{\TT{arccoth}(a)}, where \MATH{a \IN \R \SETMINUS [ -1, 1 ]}.}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\STITLE{Constants}
Constants are calculated according to the precision set in the
initialization phase (i.e. \TT{bigfloat::precision}).


\fcode{void}{constant\_E}{bigfloat \& a}
{
\MATH{a = e = 2.718281828459....}}


\fcode{void}{constant\_Pi}{bigfloat \& a}
{
\MATH{a = \pi = 3.141592653589....}}


\fcode{void}{constant\_Euler}{bigfloat \& a}
{
\MATH{a = \gamma = 0.5772156649....}}


\fcode{void}{constant\_Catalan}{bigfloat \& a}
{
\MATH{a = G = 0.9159655941....}}


\fcode{bigfloat}{E}{}{}
\fcode{bigfloat}{Pi}{}{}
\fcode{bigfloat}{Euler}{}{}
\fcode{bigfloat}{Catalan}{}{}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\IO
Let \MATH{a} be of type \BF{bigfloat}.

\BF{istream} operator \TT{>>} and \BF{ostream} operator \TT{<<}
are overloaded. Furthermore, you can use the following member
functions for writing to and reading from a file in binary or
ASCII format, respectively. Input and output of a \BF{bigfloat}
are in the following format:
\[ \PM z E \PM l \mbox{\ \  or\ \ } \PM z e \PM l,\]
where \MATH{z}  has the form \MATH{x}, \MATH{x.y} or \MATH{y}
where \MATH{x} and \MATH{y} are of type int and \MATH{l} is of
type long.  Note that you have to manage by yourself that
successive \BF{bigfloat}s have to be separated by blanks. 


\fcode{int}{a.scan\_from\_file}{FILE * fp}
{
scans \MATH{a} form the ASCII file \MATH{fp} using fscanf.}


\cfcode{int}{a.print\_to\_file}{FILE * fp}
{
prints \MATH{a} in ASCII format to the file \MATH{fp} using fprintf.}


\fcode{int}{string\_to\_bigfloat}{char * s\k bigfloat \& a}
{
converts the string \MATH{s} to a \BF{bigfloat} \MATH{a} and
returns the number of used characters.}


\fcode{int}{bigfloat\_to\_string}{const bigfloat \& a\k char * s}
{
converts the \BF{bigfloat} \MATH{a} to a string \MATH{s} and
returns the number of used characters. The number of characters
allocated for \MATH{s} must be at least \TT{a.bit\_length}()/3 + 10.
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\SEEALSO
\BF{bigint}, \BF{bigrational}, \BF{bigcomplex}.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\NOTES
The implementation of the transcendental functions is  optimized
for  the \TT{sun4} architecture.

The member functions \TT{scan\_from\_file(FILE *)}
and \TT{print\_to\_file(FILE *)} are included because there are still
compilers which do not handle \BF{fstre\-ams} correctly. In a
future release those functions will disappear.

Storing  a  double  variable  \MATH{d} into a \BF{bigfloat} \MATH{x}
(i.e. using the assignment \MATH{x = d}) is done with the
precision of the double mantissa. The precision of
IEEE doubles is 53 bits).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\EXAMPLES
The  following  program  calculates  the number \MATH{\SQRT{\pi}}
to 100 decimal places.


\begin{verbatim}
 #include <LiDIA/bigfloat.h>

 int main()
 {
   bigfloat::precision(100);
   bigfloat x = sqrt(Pi());
   cout << "\n sqrt(pi) = " << x << flush;
   return 0;
 }

\end{verbatim}

An extensive example  of \BF{bigfloat} can be found in {\LiDIA}'s
installation directory under

\begin{center}
\TT{src/simple\_classes/bigfloat\_appl.c}
\end{center}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\AUTHOR
Thomas Papanikolaou


\end{lidia_man}



