From 1b9b116f4abc29e277cdf1791f9ebf0e27aae017 Mon Sep 17 00:00:00 2001 From: matbol <48551028+matbol@users.noreply.github.com> Date: Tue, 22 Dec 2020 14:19:59 +0100 Subject: [PATCH] Compare with LSB --- bit_manipulation/power_of_2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bit_manipulation/power_of_2.cpp b/bit_manipulation/power_of_2.cpp index 2b656c3..47de6b7 100644 --- a/bit_manipulation/power_of_2.cpp +++ b/bit_manipulation/power_of_2.cpp @@ -6,7 +6,7 @@ bool powerOfTwo( int n ) { - return (n > 0 && !( n & ( n - 1 ) )); + return n>0 && !((1<<0) & n); } int main()