Exemplo n.º 1
0
 /// <summary>
 /// Вычитание с учетом знака
 /// </summary>
 /// <param name="value">Вычитаемое</param>
 /// <returns>Разность</returns>
 public BigInteger Substract(BigInteger value)
 {
     if (this.sign && value.sign)
     {
         return(this.AbsSubstract(value));
     }
     else if (!this.sign && value.sign)
     {
         BigInteger ans = this;
         ans.ChangeSign(true);
         ans = ans.AbsAdd(value);
         ans.ChangeSign(false);
         return(ans);
     }
     else if (this.sign && !value.sign)
     {
         BigInteger ans = value;
         ans.ChangeSign(true);
         ans = this.AbsAdd(ans);
         return(ans);
     }
     else
     {
         BigInteger ans1 = value;
         BigInteger ans2 = this;
         ans1.ChangeSign(true);
         ans2.ChangeSign(true);
         ans1 = ans1.Substract(ans2);
         return(ans1);
     }
 }