Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - What's the difference between c++ double and int? (I don't understand)
What's the difference between c++ double and int? (I don't understand)
Both int and double are basic data types, int is an integer and double is a floating point.

Generally speaking, the storage space occupied by int variables is as large as machine words, which is 4 bytes in a 32-bit system; 8 bytes in a 64-bit system; However, double variables generally occupy 8 bytes, and double variables occupy no less storage space than int variables.

The range of values represented by double type is larger than that represented by int, and the conversion from double value to int value will be rounded, resulting in loss of accuracy.