Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Java double b = 0.333, multiplied by 100, decimal places increase;
Java double b = 0.333, multiplied by 100, decimal places increase;
Double is a double precision type, that is to say, your D is a double, and 100 in your d* 100 is an integer (int). This is automatic type conversion.

Java will perform automatic type conversion when the following conditions are met:

(1) The data type before conversion is compatible with the data type after conversion.

(2) The representation range of the converted data type is larger than that before conversion.

The representation range of double is greater than int, and the condition (2) is satisfied. Therefore, java will automatically convert the variable 100 from the original int type to the double type.