0

I set a key to 0 and get the bitcount using the below command in redis

 set result 0
 bitcount result

I get the output to be 2 instead of 0. When i set the result to any other number and print the bitcount I get the correct number of set bits with the addition of 2. Why is 2 by default added to the bitcount's result?

Aarish Ramesh
  • 6,745
  • 15
  • 60
  • 105

1 Answers1

4

Because result holds the character "0" which is the integer 48 in decimal, which is 110000 in binary.

Agis
  • 32,639
  • 3
  • 73
  • 81