You are going to have DivideByZeroException
only in case of integer values:
int total = 3;
int numberOf = 0;
var tot = total / numberOf; // DivideByZeroException thrown
If at least one argument is a floating point value (double
in the question) you'll have FloatingPointType.PositiveInfinity as a result (double.PositiveInfinity
in the context) and no exception
double total = 3.0;
int numberOf = 0;
var tot = total / numberOf; // tot is double, tot == double.PositiveInfinity