Exemplo n.º 1
0
 /// <summary>
 /// Computes the absolute value of the given <see cref="BigInteger"/>
 /// </summary>
 /// <returns>
 /// Returns an instance of <see cref="BigInteger"/> that represents the
 /// absolute value of this instance.
 /// </returns>
 public static BigInteger Abs(BigInteger value)
 {
     return(BigIntegerMath.Abs(value));
 }
Exemplo n.º 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="value"></param>
 /// <param name="n"></param>
 /// <remarks>
 /// <para>
 /// The result is equivalent to <c>value * 2^n</c> if n is greater
 /// than or equal to 0.
 /// The shift distance may be negative which means that <paramref name="value"/> is
 /// shifted right.The result then corresponds to <c>floor(value / 2 ^ (-n))</c>.
 /// </para>
 /// <para>
 /// <strong>Note:</strong> Usage of this method on negative values is not recommended
 /// as the current implementation is not efficient.
 /// </para>
 /// </remarks>
 /// <returns></returns>
 public static BigInteger ShiftLeft(BigInteger value, int n)
 {
     return(BigIntegerMath.ShiftLeft(value, n));
 }
Exemplo n.º 3
0
 /**
  * Returns a new {@code BigInteger} whose value is greatest common divisor
  * of {@code this} and {@code val}. If {@code this==0} and {@code val==0}
  * then zero is returned, otherwise the result is positive.
  *
  * @param val
  *            value with which the greatest common divisor is computed.
  * @return {@code gcd(this, val)}.
  * @throws NullPointerException
  *             if {@code val == null}.
  */
 public static BigInteger Gcd(BigInteger a, BigInteger b)
 {
     return(BigIntegerMath.Gcd(a, b));
 }
Exemplo n.º 4
0
 /**
  * Returns a new {@code BigInteger} whose value is {@code this^exponent mod
  * m}. The modulus {@code m} must be positive. The result is guaranteed to
  * be in the interval {@code [0, m)} (0 inclusive, m exclusive). If the
  * exponent is negative, then {@code this.modInverse(m)^(-exponent) mod m)}
  * is computed. The inverse of this only exists if {@code this} is
  * relatively prime to m, otherwise an exception is thrown.
  *
  * @param exponent
  *            the exponent.
  * @param m
  *            the modulus.
  * @return {@code this^exponent mod val}.
  * @throws NullPointerException
  *             if {@code m == null} or {@code exponent == null}.
  * @throws ArithmeticException
  *             if {@code m < 0} or if {@code exponent<0} and this is not
  *             relatively prime to {@code m}.
  */
 public static BigInteger ModPow(BigInteger value, BigInteger exponent, BigInteger m)
 {
     return(BigIntegerMath.ModPow(value, exponent, m));
 }
Exemplo n.º 5
0
 /**
  * Returns a new {@code BigInteger} whose value is {@code this ^ exp}.
  *
  * @param exp
  *            exponent to which {@code this} is raised.
  * @return {@code this ^ exp}.
  * @throws ArithmeticException
  *             if {@code exp < 0}.
  */
 public static BigInteger Pow(BigInteger value, int exp)
 {
     return(BigIntegerMath.Pow(value, exp));
 }
Exemplo n.º 6
0
 /**
  * Returns a new {@code BigInteger} whose value is {@code 1/this mod m}. The
  * modulus {@code m} must be positive. The result is guaranteed to be in the
  * interval {@code [0, m)} (0 inclusive, m exclusive). If {@code this} is
  * not relatively prime to m, then an exception is thrown.
  *
  * @param m
  *            the modulus.
  * @return {@code 1/this mod m}.
  * @throws NullPointerException
  *             if {@code m == null}
  * @throws ArithmeticException
  *             if {@code m < 0 or} if {@code this} is not relatively prime
  *             to {@code m}
  */
 public static BigInteger ModInverse(BigInteger value, BigInteger m)
 {
     return(BigIntegerMath.ModInverse(value, m));
 }
Exemplo n.º 7
0
 /**
  * Returns a {@code BigInteger} array which contains {@code this / divisor}
  * at index 0 and {@code this % divisor} at index 1.
  *
  * @param divisor
  *            value by which {@code this} is divided.
  * @return {@code [this / divisor, this % divisor]}.
  * @throws NullPointerException
  *             if {@code divisor == null}.
  * @throws ArithmeticException
  *             if {@code divisor == 0}.
  * @see #divide
  * @see #remainder
  */
 public static BigInteger DivideAndRemainder(BigInteger dividend, BigInteger divisor, out BigInteger remainder)
 {
     return(BigIntegerMath.DivideAndRemainder(dividend, divisor, out remainder));
 }
Exemplo n.º 8
0
 /**
  * Returns a new {@code BigInteger} whose value is {@code this % divisor}.
  * Regarding signs this methods has the same behavior as the % operator on
  * int's, i.e. the sign of the remainder is the same as the sign of this.
  *
  * @param divisor
  *            value by which {@code this} is divided.
  * @return {@code this % divisor}.
  * @throws NullPointerException
  *             if {@code divisor == null}.
  * @throws ArithmeticException
  *             if {@code divisor == 0}.
  */
 public static BigInteger Remainder(BigInteger dividend, BigInteger divisor)
 {
     return(BigIntegerMath.Remainder(dividend, divisor));
 }
Exemplo n.º 9
0
 /**
  * Returns a new {@code BigInteger} whose value is {@code this / divisor}.
  *
  * @param divisor
  *            value by which {@code this} is divided.
  * @return {@code this / divisor}.
  * @throws NullPointerException
  *             if {@code divisor == null}.
  * @throws ArithmeticException
  *             if {@code divisor == 0}.
  */
 public static BigInteger Divide(BigInteger dividend, BigInteger divisor)
 {
     return(BigIntegerMath.Divide(dividend, divisor));
 }
Exemplo n.º 10
0
 /// <summary>
 /// Computes the negation of this <see cref="BigInteger"/>.
 /// </summary>
 /// <returns>
 /// Returns an instance of <see cref="BigInteger"/> that is the negated value
 /// of this instance.
 /// </returns>
 public static BigInteger Negate(BigInteger value)
 {
     return(BigIntegerMath.Negate(value));
 }