boost::real::real_algorithm is a C++ class that represents real numbers as a a function that calculates the n-th digit o the number, a sign and an exponent.
More...
#include <real_algorithm.hpp>
|
class | const_precision_iterator |
| is a forward iterator that iterates a boost::real::real_algorithm 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...
|
|
|
static unsigned int | maximum_precision |
|
boost::real::real_algorithm is a C++ class that represents real numbers as a a function that calculates the n-th digit o the number, a sign and an exponent.
- Author
- Laouen Mayal Louan Belloli
Because a function pointer of lambda function is used to obtain the number digits on demand, numbers with infinite representations as the irrational numbers can be represented using this class.
boost::real::real_algorithm::real_algorithm |
( |
const real_algorithm & |
other | ) |
|
|
default |
boost::real::real_algorithm::real_algorithm |
( |
int(*)(unsigned int) |
get_nth_digit, |
|
|
int |
exponent |
|
) |
| |
|
inlineexplicit |
Lambda function constructor with exponent: Creates a boost::real::real_algorithm 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. The number is positive.
- Parameters
-
get_nth_digit | - a function pointer or lambda function that given an unsigned int "n" as parameter, it returns the number n-th digit. |
exponent | - an integer representing the number exponent. |
boost::real::real_algorithm::real_algorithm |
( |
int(*)(unsigned int) |
get_nth_digit, |
|
|
int |
exponent, |
|
|
bool |
positive |
|
) |
| |
|
inlineexplicit |
Lambda function constructor with exponent and sign: Creates a boost::real::real_algorithm 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.
- Parameters
-
get_nth_digit | - a function pointer or lambda function that given an unsigned int "n" as parameter, it returns the number n-th digit. |
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. |
Construct a new boost::real::real_algorithm::con_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_algorithm::const_precision_iterator of the number.
Construct a new boost::real::real_algorithm::con_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_algorithm::const_precision_iterator of the number.
int boost::real::real_algorithm::exponent |
( |
| ) |
const |
|
inline |
- Returns
- An integer with the number exponent
unsigned int boost::real::real_algorithm::max_precision |
( |
| ) |
const |
|
inline |
Returns the maximum allowed precision, if that precision is reached and an operator need more precision, a precision_exception should be thrown.
- Returns
- an integer with the maximum allowed precision.
int boost::real::real_algorithm::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_algorithm::positive |
( |
| ) |
const |
|
inline |
- Returns
- A bool indicating if the number is positive (true) or negative (false)
void boost::real::real_algorithm::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: