From d61a575a8c1e5392ddad349c04600598ba490c0a Mon Sep 17 00:00:00 2001 From: Alessio Quaglino Date: Thu, 9 Jun 2022 02:30:31 -0700 Subject: [PATCH] Replace fabs with std::abs. Using fabs with int arguments broke the clang build on GitHub Actions, with a `-Wabsolute-value` error. PiperOrigin-RevId: 453872474 Change-Id: I5c1278e9e628b0ea3d6f26c7ee7d6925c6276850 --- src/xml/xml_util.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/xml/xml_util.cc b/src/xml/xml_util.cc index 5106b35d..5d4026fe 100644 --- a/src/xml/xml_util.cc +++ b/src/xml/xml_util.cc @@ -494,7 +494,7 @@ bool mjXUtil::SameVector(const T* vec1, const T* vec2, int n) { bool same = true; for (int i=0; i std::numeric_limits::epsilon()) { + if (std::abs(vec1[i] - vec2[i]) > std::numeric_limits::epsilon()) { same = false; } } @@ -783,13 +783,13 @@ bool mjXUtil::MapValue(XMLElement* elem, const char* attr, int* data, // check if double is int static bool isint(double x) { - return ((fabs(x - floor(x)) < 1E-12) || (fabs(x - ceil(x)) < 1E-12)); + return ((std::abs(x - floor(x)) < 1E-12) || (std::abs(x - ceil(x)) < 1E-12)); } // round to nearest int static int Round(double x) { - if (fabs(x - floor(x)) < fabs(x - ceil(x))) { + if (std::abs(x - floor(x)) < std::abs(x - ceil(x))) { return (int)floor(x); } else { return (int)ceil(x);