Division of 0 by a double not 0?

solution code: http://www.codechef.com/viewsolution/7482546
problem : SEAGM2, JULy15

in the solve function,

ld ans=win/r;
if(win==0) ans=0; //solution fails for 10 points but passes for 90 points, after removing this line
printf("%0.6Lf\n",ans);

Why is equating ans to 0 required if numerator is 0, shouldn’t ans be 0 too?

That depends on what r is. If r is also 0, ans will be NaN (Not a Number).

I found out the case for which it failed, when win!=0 the denominator will never be 0, but when win is 0 the denominator may or may not be 0, in either case the ans is 0.
Thanks.