Java Double Number Divide divide(Double numerator, Double denominator)

Here you can find the source of divide(Double numerator, Double denominator)

Description

Divides two double values, NPE save.

License

Open Source License

Parameter

Parameter Description
numerator a parameter
denominator a parameter

Return

null if the numerator is null or the denominator is null or 0.0. Else it returns the devision result.

Declaration

public static Double divide(Double numerator, Double denominator) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2010 BSI Business Systems Integration AG.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors://w w w. j a v  a 2s  .  c  om
 *     BSI Business Systems Integration AG - initial API and implementation
 ******************************************************************************/

public class Main {
    /**
     * Divides two double values, NPE save.
     * 
     * @param numerator
     * @param denominator
     * @return null if the numerator is null or the denominator is null or 0.0.
     *         Else it returns the devision result.
     */
    public static Double divide(Double numerator, Double denominator) {
        if (numerator == null || denominator == null || denominator.equals(0.0)) {
            return null;
        } else if (numerator.equals(0.0)) {
            return 0d;
        } else {
            return numerator / denominator;
        }
    }
}

Related

  1. divide(Double a, Double b)
  2. divide(double a, double b)
  3. divide(Double a, Double b)
  4. divide(double first, double second)
  5. divide(double left, double right)
  6. divide(double v1, double v2)
  7. divide(double x, double y, int scale, RoundingMode roundingMode)
  8. divide(final double n1, final double n2)
  9. divide(float a, float b)