|
| real ()=default |
| Default constructor: Constructr a boost::real::real with undefined representation and behaviour. More...
|
|
| real (const real &other) |
| Copy constructor: Creates a copy of the boost::real::real number other, if the number is an operation, then, the constructor recursively creates new copies of the other operands. More...
|
|
| real (const std::string &number) |
| String constructor: Creates a boost::real::real 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 (std::initializer_list< int > digits) |
| Initializer list constructor: Creates a boost::real::real_explicit instance that represents an integer number where all the digits parameter numbers are form the integer part in the same order. The number is set as positive. More...
|
|
| real (std::initializer_list< int > digits, bool positive) |
| Signed initializer list constructor: Creates a boost::real::real instance that represents the number where the positive parameter is used to set the number sign and the elements of the digits parameter list are the number digits in the same order. More...
|
|
| real (std::initializer_list< int > digits, int exponent) |
| Initializer list constructor with exponent: Creates a boost::real::real 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 (std::initializer_list< int > digits, int exponent, bool positive) |
| Initializer list constructor with exponent and sign: Creates a boost::real::real 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...
|
|
| real (int(*get_nth_digit)(unsigned int), int exponent) |
| Lambda function constructor with exponent: Creates a boost::real::real instance that represents the number where the exponent is used to set the number integer part and the lambda function digits is used to know the number digits, this function returns the n-th number digit. More...
|
|
| real (int(*get_nth_digit)(unsigned int), int exponent, bool positive) |
| Lambda function constructor with exponent and sign: Creates a boost::real::real instance that represents the number where the exponent is used to set the number integer part and the lambda function digits is used to know the number digit, this function returns the n-th number digit. This constructor uses the sign to determine if the number is positive or negative. More...
|
|
| ~real () |
| Default destructor: If the number is an operator, the destructor destroys its operands.
|
|
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...
|
|
const_precision_iterator | cbegin () const |
| Construct a new boost::real::real::con_precision_iterator that iterates the number approximation intervals from in increasing order according to the approximation precision. More...
|
|
const_precision_iterator | cend () const |
| Construct a new boost::real::real::con_precision_iterator that iterates the number approximation intervals from in increasing order according to the approximation precision. More...
|
|
int | operator[] (unsigned int n) const |
| If the number is an explicit or algorithm number it returns the n-th digit of the represented number. If the number is an operation it throws an invalid_representation_exception. More...
|
|
real & | operator+= (const real &other) |
| Convert the number from its current representation to an operation number representation where the operands are copies of the other and this numbers (before the conversion). The new number represent the addition operation between *this and other. More...
|
|
real | operator+ (const real &other) const |
| Creates a new boost::real::real representing an operation number where the operands are copies of the other and this numbers. The number represent the addition operation between *this and other. More...
|
|
real & | operator-= (const real &other) |
| Convert the number from its current representation to an operation number representation where the operands are copies of the other and this numbers (before the conversion). The new number representation represent the subtraction operation between *this and other. More...
|
|
real | operator- (const real &other) const |
| Creates a new boost::real::real representing an operation number where the operands are copies of the other and this numbers. The number represent the subtraction operation between *this and other. More...
|
|
real & | operator*= (const real &other) |
| Convert the number from its current representation to an operation number representation where the operands are copies of the other and this numbers (before the conversion). The new number represent the multiplication between *this and other. More...
|
|
real | operator* (const real &other) const |
| Creates a new boost::real::real representing an operation number where the operands are copies of the other and this numbers. The number represent the multiplication operation between *this and other. More...
|
|
real & | operator= (const real &other) |
| It assign a new copy of the other boost::real::real number in the *this boost::real::real number. More...
|
|
real & | operator= (const std::string &number) |
| It constructs and boost::real::real number from the std::string and assign it in the *this boost::real::real number. More...
|
|
bool | operator< (const real &other) const |
| Compares the *this boost::real::real number against the other boost::real::real number to determine if the number represented by *this is lower than the number represented by other. If the maximum precision is reached and the operator was not yet able to determine the value of the result, a precision_exception is thrown. More...
|
|
bool | operator> (const real &other) const |
| Compares the *this boost::real::real number against the other boost::real::real number to determine if the number represented by *this is greater than the number represented by other. If the maximum precision is reached and the operator was not yet able to determine the value of the result, a precision_exception is thrown. More...
|
|
bool | operator== (const real &other) const |
| Compares the *this boost::real::real number against the other boost::real::real number to determine if the number represented by *this is the same than the number represented by other. If the maximum precision is reached and the operator was not yet able to determine the value of the result, a precision_exception is thrown. More...
|
|
boost::real::real is a C++ class that represent real numbers as abstract entities that can be dynamically approximated as much as needed (until a set maximum precision) to be able to operate with them. Numbers can be added, subtracted, multiplied and compared by lower than and equality.
- Author
- Laouen Mayal Louan Belloli
A boost::real::real number is represented by the operations from which the number is created, the entire operation is represented as a binary tree where the leaves are literal numbers and the internal nodes are the operations. Also, boost::real::real allow to represent irrational numbers by taking as parameter a function pointer or lambda function that given un unsigned integer "n", the function returns the n-th digit of the irrational number.
A number can be one of the following three kind:
- Explicit number: A number is a vector of digits sorted as in the number natural representation. To determine where the integer part ends and the fractional part starts, an integer is used as the exponent of a floating point number and determines where the integer part start and the fractional ends. Also a boolean is used to set the number as positive (True) or negative (False)
- Algorithmic number: This representation is equal to the Explicit number but instead of using a vector of digits, a lambda function must be provided. The lambda function takes an unsigned integer "n" as parameter and returns the n-th digit of the number.
- A number is a composition of two numbers related by an operator (+, -, *), the number creates pointers to the operands and each time the number is used, the operation is evaluated to return the result.
Two boost::real::real numbers can be compared by the lower operator "<" and by the equal operator "==" but for those cases where the class is not able to decide the value of the result before reaching the maximum precision, a precision_exception is thrown.