From dc50effe61c833da9c15b886d5ebba65620b99f0 Mon Sep 17 00:00:00 2001 From: Samuel Fadel Date: Tue, 2 Feb 2016 17:42:04 -0200 Subject: Using std::numeric_limits where appropriate. --- forcescheme.cpp | 3 ++- scatterplot.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/forcescheme.cpp b/forcescheme.cpp index 22ab293..9e3feaa 100644 --- a/forcescheme.cpp +++ b/forcescheme.cpp @@ -1,6 +1,7 @@ #include "mp.h" #include +#include static const double EPSILON = 1e-3; @@ -18,7 +19,7 @@ arma::mat mp::forceScheme(const arma::mat &D, i[k] = j[k] = k; } - double prevDeltaSum = 1. / 0.; + double prevDeltaSum = std::numeric_limits::infinity(); for (size_t iter = 0; iter < maxIter; iter++) { double deltaSum = 0; diff --git a/scatterplot.cpp b/scatterplot.cpp index 97f2f41..acf9e36 100644 --- a/scatterplot.cpp +++ b/scatterplot.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -139,7 +140,7 @@ int QuadTree::nearestTo(float x, float y) const if (q >= 0) return q; } - float dist = 1.0f / 0.0f; + float dist = std::numeric_limits::infinity(); nearestTo(x, y, q, dist); if (dist < BRUSHING_MAX_DIST * BRUSHING_MAX_DIST) return q; -- cgit v1.2.3