示例#1
0
  public static Number numberRemainder(Number x, Number y) {
    if (Zero.numberIsZero(y)) {
      throw new ArithmeticException("Divide by zero");
    }

    Ops type = OpType.findOpType(x, y);
    if (type == Ops.DOUBLE) {
      return Remainder.doubleRemainder(Coercion.toDouble(x), Coercion.toDouble(y));
    } else if (type == Ops.BIGDECIMAL) {
      return Remainder.bigDecimalRemainder(Coercion.toBigDecimal(x), Coercion.toBigDecimal(y));
    } else if (type == Ops.RATIO) {
      return Remainder.ratioRemainder(Coercion.toRatio(x), Coercion.toRatio(y));
    } else if (type == Ops.BIGINT) {
      return Remainder.bigIntRemainder(Coercion.toBigInt(x), Coercion.toBigInt(y));
    } else {
      return Remainder.longRemainder(Coercion.toLong(x), Coercion.toLong(y));
    }
  }