diff --git a/opensfm/src/dense/src/depthmap.cc b/opensfm/src/dense/src/depthmap.cc index a665d9296..57ef85b6d 100644 --- a/opensfm/src/dense/src/depthmap.cc +++ b/opensfm/src/dense/src/depthmap.cc @@ -126,7 +126,8 @@ cv::Vec3f PlaneFromDepthAndNormal(float x, float y, const cv::Matx33d &K, } float UniformRand(float a, float b) { - return a + (b - a) * float(rand()) / RAND_MAX; + // Note that float(RAND_MAX) cannot be exactly represented as a float. We ignore the small inaccuracy here; this is already a bad way to get random numbers. + return a + (b - a) * float(rand()) / static_cast(RAND_MAX); } DepthmapEstimator::DepthmapEstimator()