type promotion in C

后端 未结 3 576
攒了一身酷
攒了一身酷 2021-01-05 08:33

I am quite confused by the following code:

#include 
#include 

int main(int argc, char ** argv)
{
    uint16_t a = 413;
    u         


        
3条回答
  •  臣服心动
    2021-01-05 08:56

    If you throw away the top-end bits of a number (by the explicit cast to a 16 bit unsigned integer) then you're going to have a result that is smaller (within the range of 0 and 2^16-1) than before.

提交回复
热议问题