Double Divide By Zero is NaN

I learned something simple today. It seems like I should have known this already but I just realized that doing a divide by 0 against a double will not result in a DivideByZeroException. This may be good or bad depending on your application but if you’re not aware of it it can result in some strange behavior.

Actually the result is only NaN if you divide 0.0 / 0.0. If you divide 1.0 / 0.0 you result in infinity.

Author: justinmchase

I'm a Software Developer from Minnesota.