List of usage examples for java.lang Double doubleValue
@HotSpotIntrinsicCandidate public double doubleValue()
From source file:com.hbc.api.trade.ota.validator.ParameterValidator.java
/** * @param paramValue ??/* ww w . ja v a2 s . com*/ * @param paramNameTip ???? */ public static void validateParamNumberGreaterThan0(Double paramValue, String paramNameTip) { if (paramValue == null || paramValue.doubleValue() < 0) { throw new ParamValidateException(CommonReturnCodeEnum.PARAM_ERROR_WITHARG, paramNameTip); } }
From source file:Main.java
/** * Converts to primitive array.//from ww w. jav a 2 s .c o m */ public static double[] values(Double[] array) { double[] dest = new double[array.length]; for (int i = 0; i < array.length; i++) { Double v = array[i]; if (v != null) { dest[i] = v.doubleValue(); } } return dest; }
From source file:Main.java
public static double[] toPrimitive(final Double[] array, final double valueForNull) { if (array == null) { return null; } else if (array.length == 0) { return EMPTY_DOUBLE_ARRAY; }//from ww w .j a va 2 s .c om final double[] result = new double[array.length]; for (int i = 0; i < array.length; i++) { final Double b = array[i]; result[i] = (b == null ? valueForNull : b.doubleValue()); } return result; }
From source file:com.hbc.api.trade.bdata.common.util.ParameterValidator.java
/** * @param paramValue ??/* www. j a va2 s.com*/ * @param paramNameTip ???? */ public static void validateParamNumberGreaterThan0(Double paramValue, String paramNameTip) { if (paramValue == null || Double.compare(paramValue.doubleValue(), 0) <= 0) { throw new ParamValidateException(CommonReturnCodeEnum.PARAM_ERROR_WITHARG, paramNameTip); } }
From source file:Main.java
public static double tanh(double t) { Double aux = new Double(sinh(t) / cosh(t)); if (aux.isNaN()) { if (t > 0.0) return 1.0; else// w ww . j av a 2 s . co m return -1.0; } return aux.doubleValue(); }
From source file:net.sourceforge.fenixedu.util.InquiriesUtil.java
public static String formatAnswer(final Double answer) { double ans = answer.doubleValue(); if (ans > 0) { return Math.floor(ans) == ans ? String.valueOf(answer.intValue()) : String.valueOf(ans); }// w w w. j a v a 2 s .co m return "-"; }
From source file:org.bibsonomy.rest.utils.HeaderUtils.java
/** * //from ww w . java2 s. co m * @param acceptHeader * the HTML ACCEPT Header * <br/>example: * <code>ACCEPT: text/xml,text/html;q=0.9,text/plain;q=0.8,image/png</code> * would be interpreted in the following precedence: * <ol> * <li>text/xml</li> * <li>image/png</li> * <li>text/html</li> * <li>text/plain</li> * </ol> * ) * @return a sorted map with the precedences */ public static SortedMap<Double, Vector<String>> getPreferredTypes(final String acceptHeader) { // maps the q-value to output format (reverse order) final SortedMap<Double, Vector<String>> preferredTypes = new TreeMap<Double, Vector<String>>( new Comparator<Double>() { @Override public int compare(Double o1, Double o2) { if (o1.doubleValue() > o2.doubleValue()) return -1; else if (o1.doubleValue() < o2.doubleValue()) return 1; else return o1.hashCode() - o2.hashCode(); } }); if (!present(acceptHeader)) { return preferredTypes; } // fill map with q-values and formats final Scanner scanner = new Scanner(acceptHeader.toLowerCase()); scanner.useDelimiter(","); while (scanner.hasNext()) { final String[] types = scanner.next().split(";"); final String type = types[0]; double qValue = 1; if (types.length != 1) { /* * FIXME: we get * java.lang.NumberFormatException: For input string: "screen" * in the error log because the format we assume seems to be * different by some clients. Until we find out, what is really * wrong (our parsing or the client), we are more careful with * parsing external data. */ try { qValue = Double.parseDouble(types[1].split("=")[1]); } catch (NumberFormatException e) { qValue = 0; log.error("Couldn't parse accept header '" + acceptHeader + "'"); } } Vector<String> v = preferredTypes.get(qValue); if (!preferredTypes.containsKey(qValue)) { v = new Vector<String>(); preferredTypes.put(qValue, v); } v.add(type); } return preferredTypes; }
From source file:net.sourceforge.fenixedu.util.InquiriesUtil.java
public static String formatAnswer(final Double answer, final Double repQuota, final Double minRepQuota) { return (repQuota.doubleValue() > minRepQuota.doubleValue()) ? formatAnswer(answer) : "-"; }
From source file:net.sourceforge.fenixedu.util.InquiriesUtil.java
public static String formatAnswer(final String answer, final Double repQuota, final Double minRepQuota) { return (repQuota.doubleValue() > minRepQuota.doubleValue()) ? formatAnswer(answer) : "-"; }
From source file:net.sourceforge.fenixedu.util.InquiriesUtil.java
public static String getTdClass(final Double val, final String[] classes, final String defaultClass, final double[] values, final Double repQuota, final Double minRepQuota) { return (repQuota.doubleValue() > minRepQuota.doubleValue()) ? getTdClass(val, classes, defaultClass, values) : defaultClass;/*from www . j a va2s . c o m*/ }