R
Rob.Meyer1
I'm working on a class for working with fractions and one of the public
functions is to return the decimal value of the fraction which is
simple enough except for when the denominator is 0. I don't want to
return 0.0 because thats not what it is, I would rather return NaN or
INF but I can't figure out how to do that. Does anyone know the
expression for either of these in doubles? Or even the bit pattern
that represents INF and/or NaN? I can't seem to find it posted
anywhere.
double Fraction:ecimal() const{
if (IsValid())
return double(n) / d;
else
return ???;
}
//n is numerator, d is denominator, of course. ??? is the expression I
need to figure out.
functions is to return the decimal value of the fraction which is
simple enough except for when the denominator is 0. I don't want to
return 0.0 because thats not what it is, I would rather return NaN or
INF but I can't figure out how to do that. Does anyone know the
expression for either of these in doubles? Or even the bit pattern
that represents INF and/or NaN? I can't seem to find it posted
anywhere.
double Fraction:ecimal() const{
if (IsValid())
return double(n) / d;
else
return ???;
}
//n is numerator, d is denominator, of course. ??? is the expression I
need to figure out.