R
R
raccoon-942014-08-07 06:54:51
Qt
raccoon-94, 2014-08-07 06:54:51

How to write two digits into one byte in Qt/C++?

Hello there is a QByteArray buf (an array of bytes in Qt) and there are two variables int a and int b . So, let's say a=3 , and b=5 how to do what would happen
|<---buf------>|
|<-----a---->|<-----b---->|
that is, so that as a result the buf element is equal to 0b00110101 or 0x35
I hope I clearly explained what I want. Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Fil, 2014-08-07
@raccoon-94

(a<<4)|b

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question