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
Forum Updated to NodeBB v4.3 + New Features

conversion from bits to bytes

Scheduled Pinned Locked Moved Solved Mobile and Embedded
4 Posts 3 Posters 1.3k 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 20 Jun 2017, 12:21 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 20 Jun 2017, 12:27
    0
    • S sandycoolxyz
      20 Jun 2017, 12:21

      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 20 Jun 2017, 12:27 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 Offline
        M Offline
        m.sue
        wrote on 20 Jun 2017, 12:29 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
          20 Jun 2017, 12:21

          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 20 Jun 2017, 12:31 last edited by
          #4

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

          1 Reply Last reply
          0

          1/4

          20 Jun 2017, 12:21

          • Login

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