Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - C language union dt {int a;; char b; Double c; } data;
C language union dt {int a;; char b; Double c; } data;
(1) * * The same entity in the memory * * * uses a storage space.

(2) The size of space is determined by the variable occupying the largest space in isomorphism.

(3) When outputting, carry out numerical analysis according to the corresponding types.

Int occupies 4 bytes.

Char takes up one byte.

Double takes up 8 bytes.

So the space occupied by data is 8 bytes.

data . a = 5; What is stored in the memory is a binary format. On X86 machines, the low order takes the following form:

00000 10 1 00000000 00000000 00000000

At this point, if you want to output: data.c, the computer will retrieve the following information from the memory:

000001010000000000000000 xxxx (xxxx stands for the upper four bytes, the data is not initialized, and the value may be uncertain).

This information: interpreted as double-precision data: one-bit symbol number+1 1 bit index bit (code shift) +52 decimal places.

(00001010000) shift = (e) original+1023 E= -943.

That is, data.c = 1.x * 2-943 is approximately equal to 0.