I've seen this finance calculation code at my friend's computer :
double Total = ...
double Paid = ...
double Wating_For_Details = ...
double Decuctibles = ...
double Rejected = ...
Well , the moment I saw this , I told him that double
is represented at base 2
and can NOT represent finance calculation. use decimal
instead.
great.
But the moment I change it to double Ive encountered :
Attempted to divide by zero.
HUH ?
Apparently - using double
, when dividing with 0.0
it does NOT throws exception :
But returns NAN
.
While my code (using decimal
) does throw exception ( when Total
is zero
)
And so I ask :
I checked 0.0==0
and it returns true. so why I'm not getting exception but NAN
? I know thats how it should be but where is the common sence of not throwing exception when dividing double by zero ?