Example usage for java.lang Double POSITIVE_INFINITY

List of usage examples for java.lang Double POSITIVE_INFINITY

Introduction

In this page you can find the example usage for java.lang Double POSITIVE_INFINITY.

Prototype

double POSITIVE_INFINITY

To view the source code for java.lang Double POSITIVE_INFINITY.

Click Source Link

Document

A constant holding the positive infinity of type double .

Usage

From source file:Main.java

public static void main(String[] args) {

    System.out.println(Double.POSITIVE_INFINITY);
}

From source file:MainClass.java

public static void main(String args[]) {
    System.out.println(Double.POSITIVE_INFINITY);
}

From source file:Main.java

public static void main(String[] args) {
    System.out.printf("%.2e %n", Double.NaN);
    System.out.printf("%.2f %n", Double.POSITIVE_INFINITY);
    System.out.printf("%.2g %n", Double.NEGATIVE_INFINITY);
    System.out.printf("%(f %n", Double.POSITIVE_INFINITY);
    System.out.printf("%(f %n", Double.NEGATIVE_INFINITY);
}

From source file:InfNaN.java

public static void main(String[] argv) {
    double d = 123;
    double e = 0;
    if (d / e == Double.POSITIVE_INFINITY)
        System.out.println("Check for POSITIVE_INFINITY works");
    double s = Math.sqrt(-1);
    if (s == Double.NaN)
        System.out.println("Comparison with NaN incorrectly returns true");
    if (Double.isNaN(s))
        System.out.println("Double.isNaN() correctly returns true");
}

From source file:FpError.java

public static void main(String[] args) {
    double res;//from   ww  w  . j  ava2 s .c  o m
    double divisor = 0;
    double dividend, root;

    // Get user input for numerator
    System.out.println("Forcing division by zero error");
    dividend = 10d;
    res = dividend / divisor;
    // Test for negative invifinity
    if (res == Double.NEGATIVE_INFINITY)
        System.out.println("result is NEGATIVE_INFINITY");
    if (res == Double.POSITIVE_INFINITY)
        System.out.println("result is POSITIVE_INFINITY");
    // Test for either infinity
    if (Double.isInfinite(res))
        System.out.println("result is infinite");

    // Get user input for square root
    System.out.println("\nCalculating square root (try negative)");
    root = 10d;
    res = Math.sqrt(root);
    if (Double.isNaN(res))
        System.out.println("result is Nan");
    else
        System.out.println("Square root = " + res);
}

From source file:alphamain.IntervalMain.java

public static void main(String[] args) {
    System.out.println("In IntervalMain class - BGN");
    System.out.println();//from   www .jav  a2  s . c o m

    System.out.println("=========Constructor");
    Interval interval = new Interval(2.3, 5.7);

    System.out.println("=========getInf()");
    System.out.println("getInf()=" + interval.getInf());

    System.out.println("=========getSup()");
    System.out.println("getSup()=" + interval.getSup());

    System.out.println("=========getSize()");
    System.out.println("getSize()=" + interval.getSize());

    System.out.println("=========getBarycenter()");
    System.out.println("getBarycenter()=" + interval.getBarycenter());

    System.out.println("=========checkPoint() & location");
    Location location = interval.checkPoint(9.0, Double.POSITIVE_INFINITY);
    System.out.println("Location=" + location);

    System.out.println();
    System.out.println("In IntervalMain class - END");
}

From source file:Main.java

/**
 * Returns next bigger double value considering precision of the argument.
 * //w  w  w.j a  va2 s.  com
 */
public static double nextUp(double d) {
    if (Double.isNaN(d) || d == Double.POSITIVE_INFINITY) {
        return d;
    } else {
        d += 0.0;
        return Double.longBitsToDouble(Double.doubleToRawLongBits(d) + ((d >= 0.0) ? +1 : -1));
    }
}

From source file:Main.java

/**
 * Replacement for the Math.nextUp(...) method that is only available in
 * HONEYCOMB and higher. Dat's some seeeeek sheeet.
 *
 * @param d/*from   www  .j  a v a2s.com*/
 * @return
 */
public static double nextUp(double d) {
    if (d == Double.POSITIVE_INFINITY)
        return d;
    else {
        d += 0.0d;
        return Double.longBitsToDouble(Double.doubleToRawLongBits(d) + ((d >= 0.0d) ? +1L : -1L));
    }
}

From source file:Calculator.Calculation.java

public static double fractionToDouble(String fraction) {
    fraction = fraction.trim();/*from   w ww.j a va  2 s .c  o m*/
    if (fraction.equals("Infinity")) {
        return Double.POSITIVE_INFINITY;
    }
    FractionFormat ff = new FractionFormat();
    Fraction fraction_a = ff.parse(fraction);
    return fraction_a.doubleValue();
}

From source file:Main.java

/**
 * Get the minimum and maximum values of an array restricting the values to either positive or negative. If <tt>positive</tt> is true,
 * only positive numbers will be addressed. If <tt>positive</tt> is false, only negative numbers will be addressed.
 * /*www  .ja  va 2 s .  c  om*/
 * @param array
 *            the array to process
 * @param positive
 *            If true, negative numbers are ignored. If false, positive numbers are ignored.
 * @return a <tt>double[]</tt> where [0]==minimum and [1]==maximum
 */
public static double[] minMaxSigned(double[] array, boolean positive) {
    double min, max;
    double val;
    if (positive) {
        min = Double.POSITIVE_INFINITY;
        max = 0;
        for (int i = 0; i < array.length; i++) {
            val = array[i];
            if (val >= 0) {
                min = (val < min) ? val : min;
                max = (val > max) ? val : max;
            }
        }
    } else {
        min = 0;
        max = Double.NEGATIVE_INFINITY;
        for (int i = 0; i < array.length; i++) {
            val = array[i];
            if (val <= 0) {
                min = (val < min) ? val : min;
                max = (val > max) ? val : max;
            }
        }
    }
    return new double[] { min, max };
}