Here you can find the source of range(double value1, double value2)
Parameter | Description |
---|---|
value1 | a parameter |
value2 | a parameter |
public static double range(double value1, double value2)
//package com.java2s; /**/*from w w w. j av a2s . c om*/ * PlotUtilities.java * * * Cytobank (TM) is server and client software for web-based management, analysis, * and sharing of flow cytometry data. * * Copyright (C) 2009 Cytobank, Inc. All rights reserved. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero 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 * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * Cytobank, Inc. * 659 Oak Grove Avenue #205 * Menlo Park, CA 94025 * * http://www.cytobank.org */ public class Main { /** * Calculates the range of any two real numbers. * Accepts input values in any order * @param value1 * @param value2 * @return double */ public static double range(double value1, double value2) { if (value1 != value2) { double min = Math.min(value1, value2); double max = Math.max(value1, value2); if ((min < 0) && (max <= 0)) { return Math.abs(min) - Math.abs(max); } else if ((min >= 0) && (max > 0)) { return Math.abs(max) - Math.abs(min); } else { return Math.abs(min) + Math.abs(max); } } // If value1 == value2 range is zero return 0; } }