Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. working with binary values directly

working with binary values directly

Scheduled Pinned Locked Moved Unsolved C++ Gurus
5 Posts 3 Posters 1.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • abdiA Offline
    abdiA Offline
    abdi
    wrote on last edited by
    #1

    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,

    1 Reply Last reply
    0
    • JohanSoloJ Offline
      JohanSoloJ Offline
      JohanSolo
      wrote on last edited by
      #2

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

      `They did not know it was impossible, so they did it.'
      -- Mark Twain

      1 Reply Last reply
      0
      • Chris KawaC Offline
        Chris KawaC Offline
        Chris Kawa
        Lifetime Qt Champion
        wrote on last edited by
        #3

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

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

        Btw. Qt is a library. It doesn't know or care about this stuff. There's no Qt code in your example whatsoever.

        1 Reply Last reply
        0
        • abdiA Offline
          abdiA Offline
          abdi
          wrote on last edited by
          #4

          Hello
          thank you about that ,errors has been vanished ,but another problem has been occurred :
          OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file /opt/opencv-3.1.0/modules/highgui/src/window.cpp, line 289
          terminate called after throwing an instance of 'cv::Exception'
          what(): /opt/opencv-3.1.0/modules/highgui/src/window.cpp:289: error: (-215) size.width>0 && size.height>0 in function imshow
          i could not find it in the net , really appreciated for helping.

          1 Reply Last reply
          0
          • JohanSoloJ Offline
            JohanSoloJ Offline
            JohanSolo
            wrote on last edited by
            #5

            I'm not an openCV expert, but the message is kind of self-explanatory: the picture you gave to the library has zero size.

            `They did not know it was impossible, so they did it.'
            -- Mark Twain

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved