Skip to content

Commit

Permalink
fix bug with big precision
Browse files Browse the repository at this point in the history
  • Loading branch information
universenox authored and sdavtaker committed Jul 11, 2019
1 parent 002a0e0 commit 12193b1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
11 changes: 5 additions & 6 deletions include/real/const_precision_iterator.hpp
Expand Up @@ -223,10 +223,9 @@ namespace boost {
*
* @return a boost::real::const_precision_iterator of the number.
*/
const_precision_iterator cend() const {
const_precision_iterator it(*this);
it.iterate_n_times(this->max_precision() - 1);
return it;
const_precision_iterator cend() {
this->iterate_n_times(this->max_precision() - _precision);
return *this;
}

interval get_interval() const {
Expand Down Expand Up @@ -287,8 +286,8 @@ namespace boost {
// If the explicit number didn't reaches the full precision (the end)
// then the number interval is defined by truncation.

for(int i = 0; i < n; i++) {
this->_approximation_interval.lower_bound.push_back(real.digits()[this->_precision]);
for(int i = _precision; i < _precision + n; i++) {
this->_approximation_interval.lower_bound.push_back(real.digits()[i]);
}

this->_approximation_interval.upper_bound.clear();
Expand Down
10 changes: 2 additions & 8 deletions include/real/real_explicit.hpp
Expand Up @@ -27,9 +27,6 @@ namespace boost {
// TODO: Add normalizations to the constructors
exact_number explicit_number;

// The number max precision is the same as the explicit number digits size.
unsigned int _maximum_precision = 1;

public:

/**
Expand Down Expand Up @@ -105,7 +102,6 @@ namespace boost {
for (const auto& c : decimal_part ) {
explicit_number.digits.push_back(c - '0');
}
this->_maximum_precision = (int)this->_digits.size();
}

/**
Expand All @@ -117,8 +113,7 @@ namespace boost {
* @param digits - an initializer_list<int> that represents the number digits.
* @param exponent - an integer representing the number exponent.
*/
real_explicit(std::initializer_list<int> digits, int exponent) : explicit_number(digits, exponent),
_maximum_precision((int)explicit_number.digits.size())
real_explicit(std::initializer_list<int> digits, int exponent) : explicit_number(digits, exponent)
{};

/**
Expand All @@ -134,8 +129,7 @@ namespace boost {
* the number is positive, otherwise is negative.
*/
real_explicit(std::initializer_list<int> digits, int exponent, bool positive) :
explicit_number(digits,exponent,positive) ,
_maximum_precision((int)explicit_number.digits.size())
explicit_number(digits,exponent,positive)
{};

/**
Expand Down

0 comments on commit 12193b1

Please sign in to comment.