Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Int and float problems in c language
Int and float problems in c language
Int and float first understand that their essence is data type and what is data type. In fact, their names tell us that just as we like to separate integers from decimals when studying, int here is integer type and float is floating point number (decimal type). Aren't these two data types?

Then why do you distinguish this? The main reason is that the computer allocates different memory space when storing data. If int (integer) is defined, it will allocate the corresponding integer size, such as 4 memory cells.

Then why did I say, for example, four memory cells? The reason is that different CPUs allocate different memory. The int allocated by a 32-bit CPU is four bytes. As for why, this is determined by the hardware design (32 bits /8=4 bytes).

To sum up, you should understand that each variable you define will be allocated a piece of memory, and the size of the allocated memory depends on your data type.