Skip to main content
Knowledgebase
Home
Renesas India - Knowledgebase

Why does 0x1217 get extended to the long type?

Latest Updated:12/01/2011

Question:

Why does 0x1217 get extended to the long type even though it has been cast to the unsigned short type?

Answer:

Even if 0x1217 is cast to the unsigned short type, it is converted to the int type because the value exceeds the range of the unsigned short type due to the following shift operation.
That is, this is a matter of operation order.
Convert it to the unsigned short type by shifting it first then casting the result.
Suitable Products