@Override public String toString() { final StringBuffer buf = new StringBuffer(); buf.append(DatatypeConverter.printInteger(OWLRealUtils.bigInteger(_numerator))); buf.append(" / "); buf.append(DatatypeConverter.printInteger(OWLRealUtils.bigInteger(_denominator))); return buf.toString(); }
@Override public String toString() { final StringBuffer buf = new StringBuffer(); buf.append(DatatypeConverter.printInteger(OWLRealUtils.bigInteger(_numerator))); buf.append(" / "); buf.append(DatatypeConverter.printInteger(OWLRealUtils.bigInteger(_denominator))); return buf.toString(); }
public static Number integerDifference(final Number a, final Number b) { final Type ta = Type.get(a.getClass()); final Type tb = Type.get(b.getClass()); if (ta == null || tb == null) { final String msg = format("Unexpected number type %s,%s passed to integerDifference method.", a.getClass().getCanonicalName(), b.getClass().getCanonicalName()); _logger.warning(msg); throw new IllegalArgumentException(msg); } final BigInteger ia = bigInteger(a); final BigInteger ib = bigInteger(b); return shrinkBigInteger(ia.subtract(ib)); }
public static Number integerSum(final Number a, final Number b) { final Type ta = Type.get(a.getClass()); final Type tb = Type.get(b.getClass()); if (ta == null || tb == null) { final String msg = format("Unexpected number type %s,%s passed to integerSum method.", a.getClass().getCanonicalName(), b.getClass().getCanonicalName()); _logger.warning(msg); throw new IllegalArgumentException(msg); } final BigInteger ia = bigInteger(a); final BigInteger ib = bigInteger(b); return shrinkBigInteger(ia.add(ib)); }
public static Number integerSum(final Number a, final Number b) { final Type ta = Type.get(a.getClass()); final Type tb = Type.get(b.getClass()); if (ta == null || tb == null) { final String msg = format("Unexpected number type %s,%s passed to integerSum method.", a.getClass().getCanonicalName(), b.getClass().getCanonicalName()); _logger.warning(msg); throw new IllegalArgumentException(msg); } final BigInteger ia = bigInteger(a); final BigInteger ib = bigInteger(b); return shrinkBigInteger(ia.add(ib)); }
public static Number integerDifference(final Number a, final Number b) { final Type ta = Type.get(a.getClass()); final Type tb = Type.get(b.getClass()); if (ta == null || tb == null) { final String msg = format("Unexpected number type %s,%s passed to integerDifference method.", a.getClass().getCanonicalName(), b.getClass().getCanonicalName()); _logger.warning(msg); throw new IllegalArgumentException(msg); } final BigInteger ia = bigInteger(a); final BigInteger ib = bigInteger(b); return shrinkBigInteger(ia.subtract(ib)); }
return shrinkBigInteger(bigInteger(n).add(BigInteger.ONE)); else
return shrinkBigInteger(bigInteger(n).add(BigInteger.ONE)); else
return shrinkBigInteger(bigInteger(n).subtract(BigInteger.ONE)); else
return shrinkBigInteger(bigInteger(n).subtract(BigInteger.ONE)); else
public static Rational simplify(final Rational r) { BigInteger n = OWLRealUtils.bigInteger(r.getNumerator()); BigInteger d = OWLRealUtils.bigInteger(r.getDenominator()); BigInteger gcd = n.gcd(d); while (!gcd.equals(BigInteger.ONE)) { n = n.divide(gcd); d = d.divide(gcd); gcd = n.gcd(d); } final Number canonicalNum = OWLRealUtils.getCanonicalObject(n); final Number canonicalDenom = OWLRealUtils.getCanonicalObject(d); if (canonicalNum.equals(r.getNumerator()) && canonicalDenom.equals(r.getDenominator())) return r; else return new Rational(canonicalNum, canonicalDenom); }
public static Rational simplify(final Rational r) { BigInteger n = OWLRealUtils.bigInteger(r.getNumerator()); BigInteger d = OWLRealUtils.bigInteger(r.getDenominator()); BigInteger gcd = n.gcd(d); while (!gcd.equals(BigInteger.ONE)) { n = n.divide(gcd); d = d.divide(gcd); gcd = n.gcd(d); } final Number canonicalNum = OWLRealUtils.getCanonicalObject(n); final Number canonicalDenom = OWLRealUtils.getCanonicalObject(d); if (canonicalNum.equals(r.getNumerator()) && canonicalDenom.equals(r.getDenominator())) return r; else return new Rational(canonicalNum, canonicalDenom); }
return shrinkBigInteger(bigInteger(n)); else if (Type.RATIONAL.equals(t))
return shrinkBigInteger(bigInteger(n)); else if (Type.RATIONAL.equals(t))
throw new IllegalArgumentException(); return bigInteger(r.getNumerator()); default: throw new IllegalArgumentException();
throw new IllegalArgumentException(); return bigInteger(r.getNumerator()); default: throw new IllegalArgumentException();
final BigInteger aprod = OWLRealUtils.bigInteger(a.getNumerator()).multiply(OWLRealUtils.bigInteger(b.getDenominator())); final BigInteger bprod = OWLRealUtils.bigInteger(b.getNumerator()).multiply(OWLRealUtils.bigInteger(a.getDenominator())); return aprod.compareTo(bprod);
final BigInteger aprod = OWLRealUtils.bigInteger(a.getNumerator()).multiply(OWLRealUtils.bigInteger(b.getDenominator())); final BigInteger bprod = OWLRealUtils.bigInteger(b.getNumerator()).multiply(OWLRealUtils.bigInteger(a.getDenominator())); return aprod.compareTo(bprod);