Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How to store integer data in memory
How to store integer data in memory
/*

* * * and the body:

Different types of variables are stored in the same storage unit. * * * The starting address used by all members in the topic has the same value.

(1) * * * The address and length of the body variable must be divisible by the size of its widest base type member.

② Its total length must be greater than or equal to the length of the widest member.

*/

In the program, because * * * uses the characteristics of body storage, the variable C takes up 4 bytes.

sizeof(int)==? 4; ? sizeof(char)* 4 = 4;

The values of c.b[0] to c.b[3] are their corresponding ASCII values 65\66\67\68 respectively.

The output of the program is 1 14525856. Namely: 68 * 2 24+67 * 2 16+66 * 2 8+65.

This shows that when storing integer data, the low bit comes first and the high bit comes last. Low 65, high 68. 66 * 2 8 times 2 8, because the position of byte store 66 ("B") is 8 bits higher than that of byte store 65 ("A"). Just like in decimal number 98, the high order is 9 and the low order is 8, so 98=9× 10+8. Because it is a high bit, it is multiplied by the bit weight of 10, indicating that symbol 9 actually represents 90.

To sum up, it is "low before and high after".