public static Number roundFloor(final Number n) { final Type t = Type.get(n.getClass()); if (t == null) { final String msg = format("Unexpected number type %s passed to roundDown method.", n.getClass().getCanonicalName()); _logger.warning(msg); throw new IllegalArgumentException(msg); } if (t.isIntegerOnly()) return n; if (Type.BIG_DECIMAL.equals(t)) { final BigDecimal d = (BigDecimal) n; final BigDecimal[] dandr = d.divideAndRemainder(BigDecimal.ONE); if (dandr[1].equals(BigDecimal.ZERO) || d.signum() == 1) return shrinkBigInteger(dandr[0].toBigIntegerExact()); else return shrinkBigInteger(dandr[0].toBigIntegerExact().subtract(BigInteger.ONE)); } else if (Type.RATIONAL.equals(t)) { final Rational r = (Rational) n; return roundFloor(r.getQuotient()); } else throw new IllegalStateException(); }
public static Number roundFloor(final Number n) { final Type t = Type.get(n.getClass()); if (t == null) { final String msg = format("Unexpected number type %s passed to roundDown method.", n.getClass().getCanonicalName()); _logger.warning(msg); throw new IllegalArgumentException(msg); } if (t.isIntegerOnly()) return n; if (Type.BIG_DECIMAL.equals(t)) { final BigDecimal d = (BigDecimal) n; final BigDecimal[] dandr = d.divideAndRemainder(BigDecimal.ONE); if (dandr[1].equals(BigDecimal.ZERO) || d.signum() == 1) return shrinkBigInteger(dandr[0].toBigIntegerExact()); else return shrinkBigInteger(dandr[0].toBigIntegerExact().subtract(BigInteger.ONE)); } else if (Type.RATIONAL.equals(t)) { final Rational r = (Rational) n; return roundFloor(r.getQuotient()); } else throw new IllegalStateException(); }
upper = OWLRealUtils.roundFloor(cu);
upper = OWLRealUtils.roundFloor(cu);