C Does operator depend on any other userdefined functions If

C++

Does operator< depend on any other user-defined functions? If so, which ones?

bool vnl_decnum::operator< (vnl_decnum const& r) const
{
#ifdef DEBUG
std::cerr << \"Entering vnl_decnum::operator< with \" << data_ << \" and \" << r.data() << \'\ \';
#endif
std::string rs = r.data();
if (data_ == \"NaN\" || rs == \"NaN\") return false; // NaN compares to nothing!
else if (operator==(r)) return false;
else if (data_ == \"Inf\") return sign_ == \'-\';
else if (rs == \"Inf\") return r.sign() == \'+\';

if (sign_==\'-\' && r.sign() == \'-\') return -r < operator-();
else if (sign_==\'-\') return true;
else if (r.sign() == \'-\') return false;
else if (sign_==\' \') return true;
else if (r.sign() == \' \') return false;
else if (data_.length()+exp_ < rs.length()+r.exp()) return true;
else if (data_.length()+exp_ > rs.length()+r.exp()) return false;
else // at this point, the orders of magnitude are the same
return comp(data_,rs);
}

bool vnl_decnum::operator< (vnl_decnum const& r) const
{
#ifdef DEBUG
std::cerr << \"Entering vnl_decnum::operator< with \" << data_ << \" and \" << r.data() << \'\ \';
#endif
std::string rs = r.data();
if (data_ == \"NaN\" || rs == \"NaN\") return false; // NaN compares to nothing!
else if (operator==(r)) return false;
else if (data_ == \"Inf\") return sign_ == \'-\';
else if (rs == \"Inf\") return r.sign() == \'+\';

if (sign_==\'-\' && r.sign() == \'-\') return -r < operator-();
else if (sign_==\'-\') return true;
else if (r.sign() == \'-\') return false;
else if (sign_==\' \') return true;
else if (r.sign() == \' \') return false;
else if (data_.length()+exp_ < rs.length()+r.exp()) return true;
else if (data_.length()+exp_ > rs.length()+r.exp()) return false;
else // at this point, the orders of magnitude are the same
return comp(data_,rs);
}

Solution

< symbols depend on

1)length() and

2)exp() functions

comparison is done between these functions

C++ Does operator< depend on any other user-defined functions? If so, which ones? bool vnl_decnum::operator< (vnl_decnum const& r) const { #ifdef DEBU

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site