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.

Drop a brain bomb

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s