What do the expression 1.0 / 0.0 will return? will it throw Exception? any compile time error? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
0

What do the expression 1.0 / 0.0 will return? will it throw Exception? any compile time error?

18th Feb 2017, 3:45 AM
Kartikeya Bhardwaj
Kartikeya Bhardwaj - avatar
2 Réponses
0
You will get Infinity. If you want to get a DivideByZeroException, do integer math like "10/0".
18th Feb 2017, 4:13 AM
Jian-hua Yeh
Jian-hua Yeh - avatar
0
it will return Double.infinity
18th Feb 2017, 4:43 AM
Kartikeya Bhardwaj
Kartikeya Bhardwaj - avatar