Here you can find the source of max(double d1, double d2)
public static double max(double d1, double d2)
//package com.java2s; /*// ww w . j a va 2 s.c o m Copyright ? 2008 Brent Boyer This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public License for more details. You should have received a copy of the Lesser GNU General Public License along with this program (see the license directory in this project). If not, see <http://www.gnu.org/licenses/>. */ public class Main { /** * Returns the maximum value of d1 and d2. * This method differs from {@link Math#max Math.max} solely in how it handles NaN inputs: * it only returns NaN if both args are NaN; * if exactly one arg is NaN, the other arg is always returned regardless of its value; * and if neither arg is NaN then the result of Math.max(d1, d2) is returned. * In contrast, Math.max always returns NaN if either arg is NaN. */ public static double max(double d1, double d2) { if (Double.isNaN(d1)) return d2; else if (Double.isNaN(d2)) return d1; else return Math.max(d1, d2); } }