+ 1

Is float d=6; correct in java?

21st Mar 2018, 4:39 PM
Vartika Pahuja
Vartika Pahuja - avatar
2 Answers
+ 19
yes , thats correct //as there will be no loss in precision of value //but in case of double to float there is loss of precision //loss of precision when higher datatyoe to lower datatype https://www.sololearn.com/Discuss/1158466/?ref=app
21st Mar 2018, 5:23 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 4
Absolutely, the compiler automatically converts 6 to 6.0, which is then a floating-point number! You can use System.out.print(d); for a better understanding ;)
21st Mar 2018, 4:46 PM
777
777 - avatar