int reverseCompare(void * a, void * b){ return normalCompare(a, b) * -1; }
BNum BNum::operator -(const BNum &other) { BNum result(0); BNum first=*this; BNum second=other; int state=normalCompare(first,second); //now we want minus second from first //maybe the nums are neg or positive //4 state: //1: first is neg & second are positve. //add twe nums and the sign of result is neg //2: first is positive & second are negetive: //add twe num and the sign of resutl is positive //3: first and second are positive: //3-1:if first is bigger: //first - seocnd & the sign of result is positive //3-2:if second is bigger: //second - first & the sign of result is negetive //4: first and second are negetive: //4-1:if first is bigger: //first-second & the sign of result is negetive //4-2:if second is bigger: //second-first & the sign of result is positive //if i said first- second it means normal minus with twe positive //1: if(first.sign==false && second.sign==true) { result=normalPlus(first,second); result.sign=false; } //2: else if(first.sign==true && second.sign==false) { result=normalPlus(first,second); result.sign=true; } //3: else if(first.sign==true && second.sign==true) { if(state==1 || state==0)//first is bigger or equal (equal contains just for true for result.sign) { result=normalMinus(first,second); result.sign=true; } else//second is bigger { result=normalMinus(second,first); result.sign=false; } } //4: else if(first.sign==true && second.sign==true) { if(state==1)//first is bigger { result=normalMinus(first,second); result.sign=false; } else//second is bigger or equal { result=normalMinus(second,first); result.sign=true; } } return result; }