DivideByZeroException and floating points

Published 03-01-2006 9:37 PM | jokiz

i was experimenting with ExpectedException attribute of NUnit when i noticed that a DivideByZeroException was not thrown when a division by zero was done within variables of type double.  instead, i got a PositiveInfinity quotient for my sample routine so I consulted the docs and it was another IEE standard issue (same as banker's rounding).

DivideByZeroException will only be thrown for int, decimal and all non-floating point numerical value types.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdividebyzeroexceptionclasstopic.asp

Filed under: , ,

Comments

# cruizer said on March 3, 2006 1:48 AM:

thanks for the heads-up jokiz!

looks like there is no such thing as 0.0 in double precision floating point! :P

# jokiz's blog said on August 17, 2006 1:24 AM:

once in a while, i fire up snipper compiler to test the .NET framework classes to investigate how they