From d0dc7eb3d2e5d84c37d3f701c232618fb7063f38 Mon Sep 17 00:00:00 2001 From: Swastika Gupta <64654203+Swastyy@users.noreply.github.com> Date: Mon, 28 Jun 2021 17:51:01 +0530 Subject: [PATCH] Update count_of_set_bits.cpp --- bit_manipulation/count_of_set_bits.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bit_manipulation/count_of_set_bits.cpp b/bit_manipulation/count_of_set_bits.cpp index 4d36b5570..84be1af7e 100644 --- a/bit_manipulation/count_of_set_bits.cpp +++ b/bit_manipulation/count_of_set_bits.cpp @@ -28,10 +28,10 @@ namespace bitCount { * @returns count , the number set bit in binary representation of n */ -std::uint64_t countSetBits(unsigned int n) { +std::uint64_t countSetBits(int n) { int count = 0; // "count" variable is used to count number of 1's in binary representation of the number while (n!=0) { - count += n&1; + count += n & 1; n=n>>1; // n=n/2 } return count;