Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Sizeof (floating-point) is _ _ _ _ _
Sizeof (floating-point) is _ _ _ _ _
Sizeof(float) is an integer expression.

The basic data types here refer to simple built-in data types such as short, int, long, float and double, because they are all related to the system.

Therefore, the values under different systems may be different, which must arouse our attention and try not to bring trouble to the transplantation of our own programs in this respect. Typically, in a 32-bit compilation environment, the value of sizeof(int) is 4.

In Pascal, sizeof () is a memory capacity measurement function that returns the size of a variable or type (in bytes). In C language, sizeof () is an operator to judge data type or expression length. In Pascal and C languages, the processing of sizeof () is carried out in the compilation stage.

Extended data

Sizeof's calculation is carried out at compile time, so it can be used as a constant expression, but it will not work in a compiler that does not fully implement the C99 standard, and the above code will also fail to compile in VC6. So we'd better think that sizeof is executed at compile time, which will not bring errors and the program is more portable.

Sizeof calculating the sizeof of an object is also converted into calculating the object type, that is, the sizeof values of different objects of the same type are consistent. Sizeof evaluates an expression, and the compiler determines the size according to the final result type of the expression, and generally does not calculate the expression.

Baidu encyclopedia -sizeof