How do C/C++ compilers handle type casting between types with different value ranges?
问题 How do type casting happen without loss of data inside the compiler? For example: int i = 10; UINT k = (UINT) k; float fl = 10.123; UINT ufl = (UINT) fl; // data loss here? char *p = "Stackoverflow Rocks"; unsigned char *up = (unsigned char *) p; How does the compiler handle this type of typecasting? A low-level example showing the bits would be highly appreciated. 回答1: Well, first note that a cast is an explicit request to convert a value of one type to a value of another type . A cast will