C++ 获取Value的第N位

public static bool getBit(int value, int bit)
{
    return ((value >> bit-1)&1)==1;
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.