c++ - qbytearray.at() to unsigned int -
OK, I have a two-part question about changing an element image for an unsigned integer ( Should a four be correct?).
Here's my code:
QByteArray data_read_buffer; Unsigned int data_recieved_size = 0; / * The code below is an external function that populates QbyteArray. Must not be important only to show that I am bytererere Specify a value for / * readFromComPortSafe (data_read_buffer); Data_recieved_size = static_cast & lt; Unsigned int & gt; ((Data_read_buffer.at (2))); OK, so as a result, I'm returning to data_recieved_size "wrong every time in a while" I go to debugger and when I observe the value of data_read_buffer I get this \ 000 \ 003 \ 203 \ 00 <205 .... (ect ect we with umlaut some character)
When I observe the value of data_recieved_size I get 4294967171
So my first question is
Am I doing something wrong with conversion on an unsigned int?
My second question is:
What does \ 203 represent in qbyteArray? I think I can not understand what I am seeing. It is my understanding that there are four types of Unicode characters ???? I was hoping to be the second element in QByteArray 0x83 or 131. How does it translate \ 203?
If someone provides some information on this, I would appreciate it.
Thanks
characters s on your platform basis May be signed or signed, in your case they are signed. When you call data_read_buffer.at and the return value is -125 : -
-125 as char is 0x83 - this value then inside
static_cast , < 0xffffff83 -
static_cast now this value is unsigned int , which simply copies the bits (well at least Less on two complementary machines). -
0xffffff83 as a unsigned int as 4,294,967,171 if you enter unsigned int And av, except for the sign extension, you should static_cast and lt; Unsigned int & gt; (Static_cast & lt; unsigned char & gt; (data_read_buffer.at (2));
Comments
Post a Comment