From b4c53af07db1b248c1cc308d153c975060de536e Mon Sep 17 00:00:00 2001 From: etagle Date: Tue, 8 Aug 2017 02:09:50 -0300 Subject: [PATCH] Adding a new macro to be able to determine if a given integer value is a power of 2 --- Marlin/macros.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Marlin/macros.h b/Marlin/macros.h index 3b79ba9b8..9c45ba38e 100644 --- a/Marlin/macros.h +++ b/Marlin/macros.h @@ -99,6 +99,9 @@ #define CBI(n,b) (n &= ~_BV(b)) #define SET_BIT(n,b,value) (n) ^= ((-value)^(n)) & (_BV(b)) +// Macro to check that a number if a power if 2 +#define IS_POWEROF2(x) ((x) && !((x) & ((x) - 1))) + // Macros for maths shortcuts #ifndef M_PI #define M_PI 3.14159265358979323846