Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - In TC20, the output result of int i=65536; printf("%d\n",i); is
In TC20, the output result of int i=65536; printf("%d\n",i); is

lz wants to experiment

short

i=65536;printf("%d\n,i); right

Yes If so, the output result is 0

I looked at the disassembly result and can I explain to you why it is 0

65536 corresponds to the hexadecimal number 10000h,

short

The result of assembly of i=65536 is

mov

[i],10000h

i only occupies The 16 bits correspond to the lower 16 bits of 10000h. The highest bit 1 is automatically discarded because it cannot be stored, so the value of i is 0

I don’t know if other compilers handle it this way, I guess. It should be almost the same,

I forgot to mention, my IDE is vs2010