use cmath std::fabs instead of cstdlib std::abs (#12075)

This commit is contained in:
江战
2022-07-20 08:59:56 +08:00
committed by GitHub
parent 616968d7bd
commit 02655fa8fa
+4 -4
View File
@@ -24,8 +24,8 @@
****************************************************************************/
#pragma once
#include <cmath>
#include <cstdint>
#include <cstdlib>
#include "base/Macros.h"
namespace cc {
@@ -65,15 +65,15 @@ inline bool isPowerOfTwo(T n) {
}
inline bool isEqualF(float lhs, float rhs, float precision = 0.000001F) {
return (std::abs(lhs - rhs) < precision);
return (std::fabs(lhs - rhs) < precision);
}
inline bool isNotEqualF(float lhs, float rhs, float precision = 0.000001F) {
return (std::abs(lhs - rhs) > precision);
return (std::fabs(lhs - rhs) > precision);
}
inline bool isNotZeroF(float v, float precision = 0.000001F) {
return (std::abs(v) > precision);
return (std::fabs(v) > precision);
}
} // namespace math