What do the expression 1.0 / 0.0 will return? will it throw Exception? any compile time error? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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 Answers
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