This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi team,
If you cast the following variable and assign it to another variable, what will be put in the assigned variable?
unsigned char A;
unsigned short B;
B=0x1234;
A=(unsigned char )B;
A=?
In my environment, 0x1234 is entered. Does casting not delete the upper 1 byte? Do you need mask processing (& 0xFF)?
Are there any precautions when casting?
Best regards,
sai
Hello,
I have brought this thread to the attention of the compiler experts. Please note that due to the local holiday, responses may be delayed.
Thanks
ki
In the C2000 compiler, the type char is 16-bits wide.
what will be put in the assigned variable?
0x1234
Does casting not delete the upper 1 byte?
The upper 8-bits are not deleted.
Do you need mask processing (& 0xFF)?
If you only want the lower 8-bits, yes.
For more on this topic, please see the article Byte Accesses with the C28x CPU.
Thanks and regards,
-George