コード例 #1
0
 Binary operator-(const Binary& other)
 {
     int maxSize = 0;
     if(strlen(this->binaryNum) > strlen(other.binaryNum))
         maxSize = strlen(this->binaryNum);
     else
         maxSize = strlen(other.binaryNum);
     Binary result = new char[maxSize + 2];
     assert(result!=NULL);
     if(this->getBinaryNum().fromBinary() > other.getBinaryNum().fromBinary())
     {
         int tmp = this->getBinaryNum().fromBinary() - other.getBinaryNum().fromBinary();
         strcpy(result.binaryNum, toBinary(tmp));
         return result.binaryNum;
     }
     else
         return 0;
 }
コード例 #2
0
 bool operator<(const Binary& other)
 {
     return this->getBinaryNum().fromBinary() < other.getBinaryNum().fromBinary();
 }
コード例 #3
0
 bool operator>(const Binary& other)
 {
     return (this->getBinaryNum().fromBinary()) > (other.getBinaryNum().fromBinary());
 }