I have defined a number of unsigned integer types as follows:\n\ntypedef unsigned char uint8;\ntypedef unsigned short uint16;\ntypedef unsigned int uint32;\ntypedfe long long uint64;\n\nIs it necessary to explicitly cast from one type of unsigned integer type to\nanother even though they do so implicitly?\n\ne.g. bytes0_1 |= (static_cast<uint16>(VersionNo)) << 12;\n\nbytes0_1 is of type uint16. Here I thought it is safer to cast VersionNo\n(type uint8) to uint16 before I do a left shift. I was just a bit worried\nabout shifting the digits off the end of an 8 bit number. Likewise in the\nstatement below I cast the result of the left shift and bit wise addition to\nuint64.\n\nbyte6 = static_cast<uint8>((MAC_Adddress >> 40) & 0xFF);\n\nMAC_Adddress is of type uint64.\n\nWhen I run QA C++ (source code analyzer) on my code it issues a few warnings\nfor the first statement:\n\nBitwise operator is being applied to a signed type.\nThis is an implicit conversion between signed and unsigned integer types.\nBe aware that an implicit conversion from 'uint16' to 'int' takes place.\n\nI think I can ignore the first two warnings as the types are actually\nunsigned integers and not signed as it thinks they are. I think the third\none means that in order to do the left shift it does an implicit conversion\nto int as operator << is just defined for int.\n\nAre these static_casts necessary? Is there a better way to write these\nstatements?