fix corner case in round, where the float is representing

a power of 2 in the mantissa
This commit is contained in:
Michael Hemmer 2010-05-11 11:41:12 +00:00
parent 7d57644b59
commit 1ab0e40c06
1 changed files with 5 additions and 3 deletions

View File

@ -279,11 +279,12 @@ round(const CORE::BigFloat& x, long rel_prec = CORE::defRelPrec.toLong() ){
// else // else
// std::cout <<"current prec: " << " SINGLETON " << std::endl; // std::cout <<"current prec: " << " SINGLETON " << std::endl;
// std::cout <<"desired prec: " << rel_prec << std::endl; // std::cout <<"desired prec: " << rel_prec << std::endl;
// std::cout <<"bitLength: " << CORE::bitLength(m) << std::endl;
// long shift = ::CORE::bitLength(m) - rel_prec - 1; // long shift = ::CORE::bitLength(m) - rel_prec - 1;
long shift ; long shift ;
if (err == 0) if (err == 0)
shift = ::CORE::bitLength(m) - rel_prec - 2; shift = ::CORE::bitLength(m) - rel_prec - 3;
else else
shift = CGAL::relative_precision(x) - rel_prec -1; shift = CGAL::relative_precision(x) - rel_prec -1;
@ -330,6 +331,7 @@ public:
CGAL_precondition(!Singleton()(x)); CGAL_precondition(!Singleton()(x));
CGAL_precondition(!CGAL::zero_in(x)); CGAL_precondition(!CGAL::zero_in(x));
x = x.abs();
NT w = Width()(x); NT w = Width()(x);
w /= ::CORE::BigFloat(x.m()-x.err(),0,x.exp()); w /= ::CORE::BigFloat(x.m()-x.err(),0,x.exp());
w = w.abs(); w = w.abs();