# working with binary values directly

• Hello dears,
These days i am going to work on qt and i am a new one in this major,i hope that help me.
so, i would like to work by binary values directly in Qt, indeed i could find some info for visual but it does not work in Qt as you can see below:

#define Ob(x) ((unsigned)Ob_(0 ## x ## uL))
#define Ob_(x) ((x & 1) | (x >> 2 & 2) | (x >> 4 & 4) | (x >> 6 & 8) |
(x >> 8 & 16) | (x >> 10 & 32) | (x >> 12 & 64) | (x >> 14 & 128)

void setup_map(pattern_map& table)
{
table.insert(std::make_pair(Ob(0001101), 0));
table.insert(std::make_pair(Ob(0011001), 1));
table.insert(std::make_pair(Ob(0010011), 2));
table.insert(std::make_pair(Ob(0111101), 3));
table.insert(std::make_pair(Ob(0100011), 4));
table.insert(std::make_pair(Ob(0110001), 5));
table.insert(std::make_pair(Ob(0101111), 6));
table.insert(std::make_pair(Ob(0111011), 7));
table.insert(std::make_pair(Ob(0110111), 8));
table.insert(std::make_pair(Ob(0001011), 9));
}

this table has problem,to be quiet honest i do not know really what should i go ??
apologize for helping.
Best,

• You could use std::bitset if you really want to manipulate bits. But usually people use hexadecimal instead of binary...

• If your compiler is C++14 compliant you can also use binary literals directly, e.g.

``````table.insert(std::make_pair(0b00001101, 0));
``````