Add more overflow guards when working with int

This commit is contained in:
Andreas Fabri 2009-07-01 15:04:34 +00:00
parent 93c04ff355
commit e4a5ffde32
1 changed files with 7 additions and 2 deletions

View File

@ -87,7 +87,7 @@ public:
CGAL_precondition (CGAL::sign (eps) == POSITIVE);
_inv_sqrt_eps = static_cast<int> (1.0 / CGAL::sqrt (_eps));
if (_inv_sqrt_eps == 0)
if (_inv_sqrt_eps <= 0)
_inv_sqrt_eps = 1;
}
@ -295,7 +295,7 @@ protected:
numer = static_cast<int> (dd * denom + 0.5);
}
}
else
else if (numer == 0)
{
while (numer == 0)
{
@ -312,6 +312,11 @@ protected:
}
}
}
else {// if numer < 0 (overflow)
numer = max_int;
denom = 1;
}
app_d = NT (numer) / NT (denom);
app_err = sqr_d - CGAL::square (app_d);