How do I get bit-by-bit data from an integer value in C?

后端 未结 8 1107
时光说笑
时光说笑 2020-11-30 17:36

I want to extract bits of a decimal number.

For example, 7 is binary 0111, and I want to get 0 1 1 1 all bits stored in bool. How can I do so?

OK, a loop is

8条回答
  •  一向
    一向 (楼主)
    2020-11-30 18:01

    Using std::bitset

    int value = 123;
    std::bitset bits(value);
    std::cout <

提交回复
热议问题