Java Utililty Methods Number Divide

List of utility methods to do Number Divide

Description

The list of methods to do Number Divide are organized into topic(s).

Method

Tdiv(Class clazz, T a, T b)
div
if (clazz == Double.class)
    return (T) Double.valueOf(a.doubleValue() / b.doubleValue());
if (clazz == Float.class)
    return (T) Float.valueOf(a.floatValue() / b.floatValue());
if (clazz == Integer.class)
    return (T) Integer.valueOf(a.intValue() / b.intValue());
if (clazz == BigDecimal.class)
    return (T) ((BigDecimal) a).divide((BigDecimal) b);
...
Doublediv(double a, double b, int len)
div
BigDecimal bdA = new BigDecimal(a);
BigDecimal bdB = new BigDecimal(b);
return bdA.divide(bdB, len, BigDecimal.ROUND_HALF_UP).doubleValue();
doublediv(double operand1, double operand2)
div
return div(operand1, operand2, 10);
doublediv(double v1, double v2)
div
return div(v1, v2, DEF_DIV_SCALE);
Doublediv(Double v1, Double v2)
div
return div(v1, v2, DEFAULT_DIV_SCALE);
doublediv(Double v1, Double v2)
div
if (v1 == null) {
    v1 = 0d;
if (v2 == null) {
    v2 = 0d;
double s1 = v1, s2 = v2;
return div(s1, s2, 4);
...
doublediv(double v1, double v2)
div
BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2));
return b1.divide(b2, 0, BigDecimal.ROUND_DOWN).doubleValue();
doublediv(double v1, double v2, int scale)
div
if (scale < 0) {
    throw new IllegalArgumentException("The scale must be a positive integer or zero");
BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2));
return b1.divide(b2, scale, BigDecimal.ROUND_HALF_UP).doubleValue();
longdiv(long v1, long v2)
div
BigDecimal b1 = new BigDecimal(v1);
BigDecimal b2 = new BigDecimal(v2);
return b1.divide(b2, 0, BigDecimal.ROUND_HALF_UP).longValue();
Objectdiv(Object a, Object b)
div
if (a == null || b == null) {
    return null;
BigDecimal decimalA = decimal(a);
BigDecimal decimalB = decimal(b);
try {
    return decimalA.divide(decimalB);
} catch (ArithmeticException ex) {
...