Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - In C language, how to ensure that there is no mistake when calculating between different ranges of plastic quantities such as int, long, unsigned int long long.
In C language, how to ensure that there is no mistake when calculating between different ranges of plastic quantities such as int, long, unsigned int long long.
Data type is very important. For example, now that all your variables are 64-bit and one variable is 32-bit, the storage space of this 32-bit variable is smaller than that of the 64-bit variable. Suppose a value can be stored in 64 bits, but not in a 32-bit variable. Is it appropriate to put it in a 32-bit variable? For 32-bit variables, this value will overflow.

printf("%d ",c); It is an integer output.

printf("%ld ",c); Output as a long integer.

These two obviously have different functions. If a number is greater than an integer (usually 32 bits), obviously %d can't be used, so we have to use %ld.