From 6659b164fe631bcd48e313a2f6d2c4f2a689c0e0 Mon Sep 17 00:00:00 2001 From: Sergey Nenakhov Date: Sun, 23 Jan 2022 00:50:18 +0100 Subject: [PATCH] intel compiler warning fixes (and fastmath in general) --- implot_internal.h | 4 ++-- implot_items.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/implot_internal.h b/implot_internal.h index 6ec2b0f..f2e9309 100644 --- a/implot_internal.h +++ b/implot_internal.h @@ -121,11 +121,11 @@ static inline T ImRemap01(T x, T x0, T x1) { return (x - x0) / (x1 - x0); } // Returns always positive modulo (assumes r != 0) static inline int ImPosMod(int l, int r) { return (l % r + r) % r; } // Returns true if val is NAN or INFINITY -static inline bool ImNanOrInf(double val) { return val == HUGE_VAL || val == -HUGE_VAL || isnan(val); } +static inline bool ImNanOrInf(double val) { return !(val >= -DBL_MAX && val <= DBL_MAX) || isnan(val); } // Turns NANs to 0s static inline double ImConstrainNan(double val) { return isnan(val) ? 0 : val; } // Turns infinity to floating point maximums -static inline double ImConstrainInf(double val) { return val == HUGE_VAL ? DBL_MAX : val == -HUGE_VAL ? - DBL_MAX : val; } +static inline double ImConstrainInf(double val) { return val >= DBL_MAX ? DBL_MAX : val <= -DBL_MAX ? - DBL_MAX : val; } // Turns numbers less than or equal to 0 to 0.001 (sort of arbitrary, is there a better way?) static inline double ImConstrainLog(double val) { return val <= 0 ? 0.001f : val; } // Turns numbers less than 0 to zero diff --git a/implot_items.cpp b/implot_items.cpp index 802bde8..8f67b37 100644 --- a/implot_items.cpp +++ b/implot_items.cpp @@ -1195,11 +1195,11 @@ IMPLOT_INLINE void PlotShadedEx(const char* label_id, const Getter1& getter1, co template void PlotShaded(const char* label_id, const T* values, int count, double y_ref, double xscale, double x0, int offset, int stride) { bool fit2 = true; - if (y_ref == -HUGE_VAL) { + if (!(y_ref > -DBL_MAX)) { // filters out nans too fit2 = false; y_ref = GetPlotLimits(IMPLOT_AUTO,IMPLOT_AUTO).Y.Min; } - if (y_ref == HUGE_VAL) { + if (!(y_ref < DBL_MAX)) { // filters out nans too fit2 = false; y_ref = GetPlotLimits(IMPLOT_AUTO,IMPLOT_AUTO).Y.Max; } @@ -1222,11 +1222,11 @@ template IMPLOT_API void PlotShaded(const char* label_id, const double* template void PlotShaded(const char* label_id, const T* xs, const T* ys, int count, double y_ref, int offset, int stride) { bool fit2 = true; - if (y_ref == -HUGE_VAL) { + if (!(y_ref > -DBL_MAX)) { // filters out nans too fit2 = false; y_ref = GetPlotLimits(IMPLOT_AUTO,IMPLOT_AUTO).Y.Min; } - if (y_ref == HUGE_VAL) { + if (!(y_ref < DBL_MAX)) { // filters out nans too fit2 = false; y_ref = GetPlotLimits(IMPLOT_AUTO,IMPLOT_AUTO).Y.Max; }