+ 5

Division By Zero Drama

So i tested this in both java and c++.When you divide a number by 0 you get a Zero Division Error.Makes sense at that point.but then on dividing that same number by 0.0 you get Infinity as your output.This behavior is weired since 0==0.0 and i cant seem to figure whats behind that change in answer.??

7th May 2018, 5:29 AM
᠌᠌Brains[Abidemi]
᠌᠌Brains[Abidemi] - avatar
1 Answer
+ 5
🇳🇬Brains - Hope this helps :) : https://stackoverflow.com/questions/12954193/why-does-division-by-zero-with-floating-point-or-double-precision-numbers-not " The first case is treated as a division on double and the later as a division on int and hence the ArthimeticException. Here is what infinity means http://docs.oracle.com/javase/7/docs/api/java/lang/Double.html#POSITIVE_INFINITY The division of doubles and floats is as per the IEEE 754standards for floating point match which shouldnt throw an exception. " Source: https://stackoverflow.com/questions/31290871/dividing-1-0-0-0-output-is-infinity Explains well: https://www.geeksforgeeks.org/g-fact-33-infinity-or-exception/
7th May 2018, 5:31 AM
Rahul George
Rahul George - avatar