/** * Returns the least common multiple of this large integer and the one * specified. * */ public IntegerSym lcm(final IntegerSym that) { if (this.isZero()&&that.isZero()){ return (IntegerSym)F.C0; } BigInteger a = fInteger.abs(); BigInteger b = that.fInteger.abs(); BigInteger gcd = fInteger.gcd(b); BigInteger lcm = (a.multiply(b)).divide(gcd); return newInstance(lcm); }
@Override public IExpr plus(final IExpr that) { if (that instanceof IntegerSym) { return this.add((IntegerSym) that); } if (isZero()) { return that; } if (that instanceof FractionSym) { return FractionSym.valueOf(fInteger).add((FractionSym) that); } return super.plus(that); }
public ISignedNumber minus(ISignedNumber that) { if (that instanceof IntegerSym) { return this.add((IntegerSym) that.negate()); } if (isZero()) { return that.negate(); } if (that instanceof FractionSym) { return FractionSym.valueOf(fInteger).minus(that); } return Num.valueOf(fInteger.doubleValue() - that.doubleValue()); }
/** * @param that * @return */ @Override public IExpr times(final IExpr that) { if (that instanceof IntegerSym) { return this.multiply((IntegerSym) that); } if (isZero()) { return F.C0; } if (that instanceof FractionSym) { return FractionSym.valueOf(fInteger).multiply((FractionSym) that); } return super.times(that); }