From fe268e6dfcce737256b0cea541943795f96433a2 Mon Sep 17 00:00:00 2001 From: "Dirk O. Kaar" Date: Fri, 11 Jun 2021 11:31:57 +0200 Subject: [PATCH] Prevent signed-flip on positive at the expense of leaving -0.0F --- cores/esp8266/Arduino.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/esp8266/Arduino.h b/cores/esp8266/Arduino.h index ee9a7964f0..0794506c9e 100644 --- a/cores/esp8266/Arduino.h +++ b/cores/esp8266/Arduino.h @@ -217,7 +217,7 @@ void optimistic_yield(uint32_t interval_us); // undefine stdlib's definitions when encountered, provide abs that supports floating point for C code #ifndef __cplusplus #undef abs -#define abs(x) ({ __typeof__(x) _x = (x); _x > 0 ? _x : -_x; }) +#define abs(x) ({ __typeof__(x) _x = (x); _x >= 0 ? _x : -_x; }) #undef round #define round(x) ({ __typeof__(x) _x = (x); _x >= 0 ? (long)(_x + 0.5) : (long)(_x - 0.5); }) #endif // ifndef __cplusplus