List of usage examples for java.lang Double NaN
double NaN
To view the source code for java.lang Double NaN.
Click Source Link
From source file:Main.java
/** Helper method - gets a named attribute's value as a <I>float</I>. @param pNodeMap The <I>NamedNodeMap</I>. @param strName Name of the attribute. @return Value of the attribute./* w ww.j ava2 s. c o m*/ */ public static float getAttributeFloat(NamedNodeMap pNodeMap, String strName) throws ClassCastException, NumberFormatException { double dblReturn = getAttributeDouble(pNodeMap, strName); if (Double.NaN == dblReturn) return Float.NaN; return (float) dblReturn; }
From source file:Main.java
/** Helper method - gets a named element's value as a <I>float</I>. @param pElement The parent <I>Element</I>. @param strName Name of the element./*w w w . j a v a2 s .c om*/ @return Value of the element. */ public static float getElementFloat(Element pElement, String strName) throws ClassCastException, NumberFormatException { double dblReturn = getElementDouble(pElement, strName); if (Double.NaN == dblReturn) return Float.NaN; return (float) dblReturn; }
From source file:Main.java
/** * Determines the minimum and maximum values in the <tt>array</tt>. Calls {@link #minMax(double[], double)} with <tt>Double.NaN</tt> as * the <tt>noDataValue</tt>. * /*from www .java 2 s. c om*/ * @param array * @return a <tt>double[]</tt> where [0]==minimum and [1]==maximum * @see #minMax(double[], double) */ public static double[] minMax(double[] array) { return minMax(array, Double.NaN); }
From source file:Main.java
/** Helper method - gets a named element's value as a <I>double</I>. @param pElement The parent <I>Element</I>. @param strName Name of the element./*w ww . j a va2 s. c o m*/ @return Value of the element. */ public static double getElementDouble(Element pElement, String strName) throws ClassCastException, NumberFormatException { String strValue = getElementString(pElement, strName); if (null == strValue) return Double.NaN; return Double.parseDouble(strValue); }
From source file:Calculator.java
public static double calculate(double op1, double op2, String operation) { switch (operation) { case "+": return op1 + op2; case "-": return op1 - op2; case "*": return op1 * op2; case "/": return op1 / op2; }//from w w w .j a v a2s . c o m return Double.NaN; }
From source file:Main.java
/** Locate a sub-element tagged 'name', return its value. * * @param element Element where to start looking. May be null. * @param name Name of sub-element to locate. * * @return Returns string that was found or NaN * @throws Exception on error in number format *///from w w w . j a va 2 s . c o m final public static double getSubelementDouble(final Element element, final String name) throws Exception { return getSubelementDouble(element, name, Double.NaN); }
From source file:Main.java
/** Helper method - gets a named attribute's value as a <I>double</I>. @param pNodeMap The <I>NamedNodeMap</I>. @param strName Name of the attribute. @return Value of the attribute.//from w w w . ja va2s .c o m */ public static double getAttributeDouble(NamedNodeMap pNodeMap, String strName) throws ClassCastException, NumberFormatException { String strValue = getAttributeString(pNodeMap, strName); if (null == strValue) return Double.NaN; return Double.parseDouble(strValue); }
From source file:Main.java
public static double getQuantile(Collection<Double> l, double alpha) { List<Double> sorted = new ArrayList<Double>(l); Collections.sort(sorted);/*from w ww .j av a 2s . c o m*/ int size = sorted.size(); if (size == 0) return Double.NaN; double kDouble = (size - 1) * alpha; int k = (int) Math.floor(kDouble); double g = kDouble - k; double lowerValue = sorted.get(k); if (sorted.size() <= k + 1) return lowerValue; double upperValue = sorted.get(k + 1); return (1 - g) * lowerValue + g * upperValue; }
From source file:Main.java
/** * For a double precision value x, this method returns +1.0 if x >= 0 and * -1.0 if x < 0. Returns <code>NaN</code> if <code>x</code> is * <code>NaN</code>.//from w w w .j a va 2s . c o m * * @param x the value, a double * @return +1.0 or -1.0, depending on the sign of x */ public static double indicator(final double x) { if (Double.isNaN(x)) { return Double.NaN; } return (x >= 0.0) ? 1.0 : -1.0; }
From source file:com.candy.algo.SMA.java
public static double[] Sma(double inputs[], int windowSize) { // Get a DescriptiveStatistics instance DescriptiveStatistics stats = new DescriptiveStatistics(); stats.setWindowSize(windowSize);/*from www . j a v a2s . c o m*/ double[] sma = new double[inputs.length]; for (int i = 0; i < inputs.length; i++) { stats.addValue(inputs[i]); if (i >= (windowSize - 1)) sma[i] = stats.getMean(); else sma[i] = Double.NaN; } return sma; }