Expand|Select|Wrap|Line Numbers
- switch (opcode) {
- case GCD: out = b1.gcd(b2).toString();
- break;
Expand|Select|Wrap|Line Numbers
- /**
- * Returns a BigInteger whose value is the greatest common divisor of
- * <tt>abs(this)</tt> and <tt>abs(val)</tt>. Returns 0 if
- * <tt>this==0 && val==0</tt>.
- *
- * @param val value with with the GCD is to be computed.
- * @return <tt>GCD(abs(this), abs(val))</tt>
- */
- public BigInteger gcd(BigInteger val) {
- if (val.signum == 0)
- return this.abs();
- else if (this.signum == 0)
- return val.abs();
- MutableBigInteger a = new MutableBigInteger(this);
- MutableBigInteger b = new MutableBigInteger(val);
- MutableBigInteger result = a.hybridGCD(b);
- return new BigInteger(result, 1);
- }