conversion from bits to bytes
Solved
Mobile and Embedded
-
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 ? -
@sandycoolxyz Maybe some bit manipulation tutorial will help: http://www.cprogramming.com/tutorial/bitwise_operators.html
-
@sandycoolxyz
Hi,get number: i=6*2**12+20*2**6+63
get bytes as QByteArray: QByteArray::number(i,16)-Michael.
-
@sandycoolxyz Maybe you can also use std::bitset.