From 370e8641a24e8d367776ffeb0fd387daccbb2390 Mon Sep 17 00:00:00 2001 From: Armando Luiz Nicolini Delgado <nicolui@inf.ufpr.br> Date: Sun, 24 Apr 2022 17:46:30 -0300 Subject: [PATCH] =?UTF-8?q?/*=20isPot2()n=20agora=20=C3=A9=20uma=20macro?= =?UTF-8?q?=20que=20n=C3=A3o=20usa=20log2().=20Ver=20'utils.h'=20*/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/utils.c | 2 ++ utils/utils.h | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/utils/utils.c b/utils/utils.c index 53aeb74..fe9bd3c 100644 --- a/utils/utils.c +++ b/utils/utils.c @@ -33,8 +33,10 @@ string_t markerName(string_t baseName, int n) } +/* int isPot2(int n) { int k; return (k = log2(n)) == log2(n) ; } +*/ diff --git a/utils/utils.h b/utils/utils.h index acb7d5d..b48f3c2 100644 --- a/utils/utils.h +++ b/utils/utils.h @@ -16,7 +16,9 @@ typedef char * string_t; double timestamp(void); string_t markerName(string_t baseName, int n); -int isPot2 (int n); +// int isPot2 (int n); + +#define isPot2(n) (n && !(n & (n - 1))) #endif // __UTILS_H__ -- GitLab