Java Utililty Methods Double Number Divide

List of utility methods to do Double Number Divide

Description

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

Method

Stringdivide(String thisVal, String addVal)
divide
String result = null;
BigDecimal one = new BigDecimal(thisVal == null ? "0" : thisVal);
BigDecimal two = new BigDecimal(addVal == null ? "0" : addVal);
result = one.divide(two).toString();
return result;
doubledivide4Money(Double value1, Double value2)
divide Money
return getScaleValue4Money(defaultValue(value1).doubleValue() / defaultValue(value2).doubleValue());
double[]divideComplex(double realOne, double imagOne, double realTwo, double imagTwo)
Divides two complex values
double[] revan = new double[2];
double denominator = Math.pow(realTwo, 2) + Math.pow(imagTwo, 2);
revan[0] = ((realOne * realTwo) + (imagOne * imagTwo)) / denominator;
revan[1] = ((imagOne * realTwo) - (realOne * imagTwo)) / denominator;
return revan;
doubledivideDouble(double first, double second)
divide Double
BigDecimal b1 = new BigDecimal(first);
BigDecimal b2 = new BigDecimal(second);
return b1.divide(b2).doubleValue();
doubledivideDouble(double first, double second, int scale, int roundingMode)
divide Double
BigDecimal b1 = new BigDecimal(first);
BigDecimal b2 = new BigDecimal(second);
if (roundingMode == -1) {
    roundingMode = BigDecimal.ROUND_HALF_EVEN;
return b1.divide(b2, scale, BigDecimal.ROUND_HALF_EVEN).doubleValue();
doubledivideInts(int numerator, int denominator)
Provides exact division of two integer values by using BigDecimal division.
BigDecimal result = BigDecimal.valueOf(numerator).divide(BigDecimal.valueOf(denominator), DECIMAL_SCALE,
        BigDecimal.ROUND_HALF_UP);
return result.doubleValue();
StringdivideNumber(Object divisor, Object dividend)
divide Number
if (divisor == null || dividend == null) {
    return "";
BigDecimal a = toBig(divisor);
BigDecimal b = toBig(dividend);
if (a.equals(toBig(0)) || b.equals(toBig(0))) {
    return "0";
BigDecimal c = a.divide(b, 2, BigDecimal.ROUND_DOWN);
return c.toString();
doubledivZ(double z)
Returns the reciprocal of a number, or zero if undefined.
return z == 0 ? 1 : 1 / z;
intgetIntDividedCeil(final int nDividend, final int nDivisor)
get Int Divided Ceil
return getIntDivided(nDividend, nDivisor, RoundingMode.CEILING);
longgetLongDivided(final long nDividend, final long nDivisor, @Nonnull final RoundingMode eRoundingMode)
get Long Divided
return new BigDecimal(nDividend).divide(new BigDecimal(nDivisor), eRoundingMode).longValue();