Integer types and precision floating point types
int is 4 bytes, 32 bits.
Its 4 bytes are completely used for integers, that is, only numbers such as 1, 2, and 3 can be displayed, and the numbers after the decimal point cannot be displayed. The data range is -2147483648~2147483647[-2^31~2^31-1].
float is also 4 bytes, 32 bits.
But its bytes are distributed like this: 1bit (sign bit) 8bits (exponent bit) 23bits (mantissa bit), it can display the numbers after the decimal point, but only 7 bits can be displayed. The range of float is -2^128 ~ +2^128, which is -3.40E+38 ~ +3.40E+38.
So it stands to reason that float should contain int type.
The difference between single precision and double precision
double is 8 bytes, 64 bits.
Its bytes are distributed like this: 1bit (sign bit), 11bits (exponent bit), 52bits (mantissa bit), and it can also display the decimal part, which can display 16 bits, which is more accurate than single-precision float. The range of double is -2^1024 ~ +2^1024, which is -1.79E+308 ~ +1.79E+308.
Recently, I was reviewing the Blue Bridge Cup, and I also re-read the long-lost c/c++. These are some small problems I encountered in the process of brushing the questions. Some basic knowledge points of c/c++ will be updated in the future. If you have any questions, you can leave a message to discuss in the comment area.