Here you can find the source of divide(Double numerator, Double denominator)
Parameter | Description |
---|---|
numerator | a parameter |
denominator | a parameter |
public static Double divide(Double numerator, Double denominator)
//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; } } }