Boost.Real  1.0.0
Boost.Real numerical data type for real numbers representation using range arithmetic.
boost::real::real_explicit Class Reference

boost::real::real_explicit is a C++ class that fully represents real numbers as a vector of digits, a sign and an exponent. More...

#include <real_explicit.hpp>

Classes

class  const_precision_iterator
 is a forward iterator that iterates a boost::real::real_explicit number approximation intervals. The iterator calculates the initial interval with the initial precision and then it increase the precision in each iteration (++) and recalculate the interval. More...
 

Public Member Functions

 real_explicit ()=default
 Default constructor: Construct an empty boost::real::real_explicit with undefined representation and behaviour.
 
 real_explicit (const real_explicit &other)=default
 Copy constructor: Creates a copy of the boost::real::real_explicit number other. More...
 
 real_explicit (const std::string &number)
 String constructor: Creates a boost::real::real_explicit instance by parsing the string. The string must have a valid number, in other case, the constructor will throw an boost::real::invalid_string_number exception. More...
 
 real_explicit (std::initializer_list< int > digits, int exponent)
 Initializer list constructor with exponent: Creates a boost::real::real_explicit instance that represents the number where the exponent is used to set the number integer part and the elements of the digits list are the digits the number in the same order. The number is set as positive. More...
 
 real_explicit (std::initializer_list< int > digits, int exponent, bool positive)
 Initializer list constructor with exponent and sign: Creates a boost::real::real_explicit instance that represents the number where the exponent is used to set the number integer part and the elements of the digit list are the digits the number in the same order. This constructor uses the sign to determine if the number is positive or negative. More...
 
unsigned int max_precision () const
 Returns te maximum allowed precision, if that precision is reached and an operator need more precision, a precision_exception should be thrown. More...
 
void set_maximum_precision (unsigned int maximum_precision)
 Set a new maximum precision for the instance. More...
 
int exponent () const
 
bool positive () const
 
const std::vector< int > & digits () const
 
const_precision_iterator cbegin () const
 Construct a new boost::real::real_explicit::const_precision_iterator that iterates the number approximation intervals in increasing order according to the approximation precision. More...
 
const_precision_iterator cend () const
 Construct a new boost::real::real_explicit::const_precision_iterator that iterates the number approximation intervals in increasing order according to the approximation precision. More...
 
int operator[] (unsigned int n) const
 Returns the n-th digit the number. More...
 
real_explicitoperator= (const real_explicit &other)=default
 It assign a new copy of the other boost::real::real_explicit number in the *this boost::real::real_explicit number. More...
 

Detailed Description

boost::real::real_explicit is a C++ class that fully represents real numbers as a vector of digits, a sign and an exponent.

Author
Laouen Mayal Louan Belloli

Constructor & Destructor Documentation

boost::real::real_explicit::real_explicit ( const real_explicit other)
default

Copy constructor: Creates a copy of the boost::real::real_explicit number other.

Parameters
other- the boost::real::real instance to copy.
boost::real::real_explicit::real_explicit ( const std::string &  number)
inlineexplicit

String constructor: Creates a boost::real::real_explicit instance by parsing the string. The string must have a valid number, in other case, the constructor will throw an boost::real::invalid_string_number exception.

Parameters
number- a valid string representing a number.
Exceptions
boost::real::invalid_string_numberexception
boost::real::real_explicit::real_explicit ( std::initializer_list< int >  digits,
int  exponent 
)
inline

Initializer list constructor with exponent: Creates a boost::real::real_explicit instance that represents the number where the exponent is used to set the number integer part and the elements of the digits list are the digits the number in the same order. The number is set as positive.

Parameters
digits- an initializer_list<int> that represent the number digits.
exponent- an integer representing the number exponent.
boost::real::real_explicit::real_explicit ( std::initializer_list< int >  digits,
int  exponent,
bool  positive 
)
inline

Initializer list constructor with exponent and sign: Creates a boost::real::real_explicit instance that represents the number where the exponent is used to set the number integer part and the elements of the digit list are the digits the number in the same order. This constructor uses the sign to determine if the number is positive or negative.

Parameters
digits- an initializer_list<int> that represent the number digits.
exponent- an integer representing the number exponent.
positive- a bool that represent the number sign. If positive is set to true, the number is positive, otherwise is negative.

Member Function Documentation

const_precision_iterator boost::real::real_explicit::cbegin ( ) const
inline

Construct a new boost::real::real_explicit::const_precision_iterator that iterates the number approximation intervals in increasing order according to the approximation precision.

The iterator starts pointing the interval with the minimum precision.

Returns
a boost::real::real_explicit::const_precision_iterator of the number.
const_precision_iterator boost::real::real_explicit::cend ( ) const
inline

Construct a new boost::real::real_explicit::const_precision_iterator that iterates the number approximation intervals in increasing order according to the approximation precision.

The iterator starts pointing the interval with the maximum allowed precision.

Returns
a boost::real::real_explicit::const_precision_iterator of the number.
const std::vector<int>& boost::real::real_explicit::digits ( ) const
inline
Returns
a const reference to the vector holding the number digits
int boost::real::real_explicit::exponent ( ) const
inline
Returns
An integer with the number exponent
unsigned int boost::real::real_explicit::max_precision ( ) const
inline

Returns te maximum allowed precision, if that precision is reached and an operator need more precision, a precision_exception should be thrown.

Returns
and integer with the maximum allowed precision.
real_explicit& boost::real::real_explicit::operator= ( const real_explicit other)
default

It assign a new copy of the other boost::real::real_explicit number in the *this boost::real::real_explicit number.

Parameters
other- the boost::real::real_explicit number to copy.
Returns
a reference of *this with the new represented number.
int boost::real::real_explicit::operator[] ( unsigned int  n) const
inline

Returns the n-th digit the number.

Parameters
n- an unsigned int number indicating the index of the requested digit.
Returns
an integer with the value of the number n-th digit.
bool boost::real::real_explicit::positive ( ) const
inline
Returns
A bool indicating if the number is positive (true) or negative (false)
void boost::real::real_explicit::set_maximum_precision ( unsigned int  maximum_precision)
inline

Set a new maximum precision for the instance.

Parameters
maximum_precision- an unsigned int to set as the new precision.

The documentation for this class was generated from the following file: