Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. conversion from bits to bytes

conversion from bits to bytes

Scheduled Pinned Locked Moved Solved Mobile and Embedded
4 Posts 3 Posters 1.5k 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.
  • S Offline
    S Offline
    sandycoolxyz
    wrote on last edited by
    #1

    hi,
    I use qt 4.8.5.
    I wanted convert date(mmdd) into 10 bit value and add a constant of 6 bits.send it as two bytes.
    eg. 0620 (june 20)
    06 - 0110b
    20 - 0001 0100b
    constant - 111111b
    So when you combine - 0110 010100 111111 (06 20 constant) -----> 0110 0101 0011 1111.
    i.e 0x653F (save this in qbyte array)
    how can i convert number into bits and then save result in qbytearray ?

    E 2 Replies Last reply
    0
    • S sandycoolxyz

      hi,
      I use qt 4.8.5.
      I wanted convert date(mmdd) into 10 bit value and add a constant of 6 bits.send it as two bytes.
      eg. 0620 (june 20)
      06 - 0110b
      20 - 0001 0100b
      constant - 111111b
      So when you combine - 0110 010100 111111 (06 20 constant) -----> 0110 0101 0011 1111.
      i.e 0x653F (save this in qbyte array)
      how can i convert number into bits and then save result in qbytearray ?

      E Offline
      E Offline
      Eeli K
      wrote on last edited by
      #2

      @sandycoolxyz Maybe some bit manipulation tutorial will help: http://www.cprogramming.com/tutorial/bitwise_operators.html

      1 Reply Last reply
      1
      • m.sueM Offline
        m.sueM Offline
        m.sue
        wrote on last edited by m.sue
        #3

        @sandycoolxyz
        Hi,

        get number: i=6*2**12+20*2**6+63
        get bytes as QByteArray: QByteArray::number(i,16)

        -Michael.

        1 Reply Last reply
        1
        • S sandycoolxyz

          hi,
          I use qt 4.8.5.
          I wanted convert date(mmdd) into 10 bit value and add a constant of 6 bits.send it as two bytes.
          eg. 0620 (june 20)
          06 - 0110b
          20 - 0001 0100b
          constant - 111111b
          So when you combine - 0110 010100 111111 (06 20 constant) -----> 0110 0101 0011 1111.
          i.e 0x653F (save this in qbyte array)
          how can i convert number into bits and then save result in qbytearray ?

          E Offline
          E Offline
          Eeli K
          wrote on last edited by
          #4

          @sandycoolxyz Maybe you can also use std::bitset.

          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