Skip to content

Commit 17bacf0

Browse files
committed
Correcting two double 1e-15 constant calculations.
In recent commits started setting two 1e-15 values with the calculation: = 1/std::numeric_limits<DBL>::digits10; when I meant to code: = 1/pow(10,std::numeric_limits<DBL>::digits10); Both forms bad practice in not being specific as to the types for the explicit values. The first returns integer 0, later cast to double and I got away with it in all but my full set of test cases. Corrected: = (DBL)1.0/pow((DBL)10.0,std::numeric_limits<DBL>::digits10);
1 parent a5a1e6a commit 17bacf0

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

source/core/math/polynomialsolver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ static bool regula_falsa(const int order, const DBL *coef, DBL a, DBL b, DBL *va
744744

745745
break;
746746
}
747-
else if (fabs(fx) < (1/std::numeric_limits<DBL>::digits10))
747+
else if (fabs(fx) < ((DBL)1.0/pow((DBL)10.0,std::numeric_limits<DBL>::digits10)))
748748
{
749749
*val = x;
750750

source/core/shape/blob.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,10 @@ const DBL DEPTH_TOLERANCE = MIN_ISECT_DEPTH;
143143
/// @note
144144
/// Value for @ref INSIDE_TOLERANCE was since v1.0 set to 1.0e-6 which is a good
145145
/// value if running single floats. With double floats a value of 1e-15 is better.
146-
/// This is an offset to the inside of the 0.0 density surface after the blob
146+
/// This is an offset to the outside of the 0.0 density surface after the blob
147147
/// threshold is subtracted. Now using std::numeric_limits to set.
148148
///
149-
const DBL INSIDE_TOLERANCE = 1/std::numeric_limits<DBL>::digits10;
149+
const DBL INSIDE_TOLERANCE = (DBL)1.0/pow((DBL)10.0,std::numeric_limits<DBL>::digits10);
150150

151151
/* Ray enters/exits a component. */
152152
const int ENTERING = 0;

0 commit comments

Comments
 (0)