简体   繁体   English

在Redis中使用bitcount命令

[英]Using bitcount command in redis

I set a key to 0 and get the bitcount using the below command in redis 我将密钥设置为0并在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? 我得到的输出是2而不是0。当我将结果设置为任何其他数字并打印位计数时,我得到正确的设置位数,加上2。为什么默认情况下将2加到位计数的结果上?

因为result包含字符"0" ,它是十进制的整数48 ,二进制的110000

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM