Untitled
bool bigNum::operator<(const bigNum &rhs) const { if (this->sign && !rhs.sign) { return false; } else if (!this->sign && rhs.sign) { return true; } else if (this->digits < rhs.digits) { return true; } else if (this->digits > rhs.digits) { return false; } else { int i = 0; while (i != this->digits) { if (this->number[i] > rhs.number[i]) { return false; } if (this->number[i] < rhs.number[i]) { return true; } i++; } return false; } } bool bigNum::operator<(long long rhs) const { //call constructor and put rhs into it bigNum num(rhs); return *this < num; } bool bigNum::operator>(long long rhs) const { bigNum num(rhs); return *this > num; } bool bigNum::operator==(const bigNum &rhs) const { int i = 0; while (i <= this->digits) { if (this->number[i] != rhs.number[i]) { return false; } i++; } return true; }
Leave a Comment