Java Double Number Format formatDoubleInfinity(Double d)

Here you can find the source of formatDoubleInfinity(Double d)

Description

format Double Infinity

License

Open Source License

Declaration

public static Double formatDoubleInfinity(Double d) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * This file is part of ISPyB.//from w  ww. j  av a2  s . c  o m
 * 
 * ISPyB 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.
 * 
 * ISPyB 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 Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with ISPyB.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * Contributors : S. Delageniere, R. Leal, L. Launer, K. Levik, S. Veyrier, P. Brenchereau, M. Bodin, A. De Maria Antolinos
 ******************************************************************************/

public class Main {
    public static Double formatDoubleInfinity(Double d) {
        if (d == null)
            return null;
        if (d.equals(Double.POSITIVE_INFINITY)) {
            return Double.MAX_VALUE;
        } else if (d.equals(Double.NEGATIVE_INFINITY)) {
            return Double.MIN_VALUE;
        } else if (d.equals(Double.NaN)) {
            return null;
        } else
            return d;
    }
}

Related

  1. formatDouble(final Object value)
  2. formatDouble(String value)
  3. formatDoubleAsString(double num, int n)
  4. formatDoubleFast(double source, int decimals, int precision, StringBuffer target)
  5. formatDoubleForDecimalPlaces(double d, int decimalcount)
  6. formatDoublePrecise(double source, int decimals, int precision, StringBuffer target)
  7. formatDoubleToFixedLength(String value, int length)
  8. formatDoubleToString(double d)
  9. formatDoubleToString(double n)