Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Can the C++ language keep decimals?
Can the C++ language keep decimals?
Int type is an integer (prefix is not discussed here), and its value range is -2 3 1 ~ 2 3 1.

Int can only be an integer, that is, if you declare an int a and assign 1 to A, A is equal to 1. And if 1.4 is assigned to A, A is still equal to1; Assign 1.9 to a, and A is still equal to 1.

Therefore, integers only store the integer part of the given data, and the decimal part is directly ignored and not rounded.

Float single-precision floating-point type contains decimal points, but it does not mean that only decimal points can be assigned. You can assign it a number with a decimal point, or you can assign it an integer directly. The floating range is 3.4e-38~3.4e+38 (scientific counting method is 3.4 *10-38 ~ 3.4 *10 38).

I hope the landlord can understand, but if you don't understand, you can continue to ask.