why did you declare your method as const ?
try without.
I thought that as long as a function doesn't change anything within the class it's consdiered a constant function?
Regarding the double comparisons, you're right I've forgotten about floating point stuff. I'll try and se if I can compute my machine eps. If there is one I might as well declare that as machine eps.
*edit*
Tried removing the constant part, but it still complains. It looks like it doesn't like non constant function being used by constant functions either. The error message is the same as before.
Interval Interval::operator *(const Interval& obj) const {
if ((hi < 0.0) && (obj.lo > 0.0))
return Interval(lo*obj.hi, hi*obj.lo);
else if (hasZero() && (obj.lo > 0.0)) *<--- this line*
return Interval(lo*obj.hi, hi*obj.hi);
else if ((lo > 0.0) && (obj.lo > 0.0))
return Interval(lo*obj.lo, hi*obj.hi);
else if ((hi < 0.0) && (obj.hasZero())) *<--- this line*
return Interval(lo*obj.hi, lo*obj.lo);
else if ((lo > 0.0) && (obj.hasZero())) *<--- this line*
return Interval(hi*obj.lo, hi*obj.hi);
else if ((hi < 0.0) && (obj.hi < 0.0))
return Interval(hi*obj.hi, lo*obj.lo);
else if ((hasZero()) && (obj.hi < 0.0)) *<--- this line*
return Interval(hi*obj.lo, lo*obj.lo);
else if ((lo > 0.0) && (obj.hi < 0.0))
return Interval(hi*obj.lo, lo*obj.hi);
else {
return Interval(min(min(lo*obj.lo, lo*obj.hi), min(hi*obj.lo, hi*obj.hi)), *<--- this line*
max(max(lo*obj.lo, lo*obj.hi), max(hi*obj.lo, hi*obj.hi))); *<--- this line*
}
}
double min(double a, double b) {
if (a <= b)
return a;
else
return b;
}
double max(double a, double b) {
if (a <= b)
return b;
else
return a;
}
Edited by magnus80a, 26 December 2005 - 04:19 AM.