List of usage examples for java.lang Double toString
public String toString()
From source file:Main.java
/** * Return the data stored in the cursor at the given index and given position * (ie the given row which the cursor is currently on) as null OR a String. * <p>/*from w w w. j a va 2 s . c o m*/ * NB: Currently only checks for Strings, long, int, and double. * * @param c * @param i * @return */ @SuppressLint("NewApi") public static String getIndexAsString(Cursor c, int i) { // If you add additional return types here be sure to modify the javadoc. if (i == -1) return null; if (c.isNull(i)) { return null; } switch (c.getType(i)) { case Cursor.FIELD_TYPE_STRING: return c.getString(i); case Cursor.FIELD_TYPE_FLOAT: { // the static version of this seems to have problems... Double d = c.getDouble(i); String v = d.toString(); return v; } case Cursor.FIELD_TYPE_INTEGER: { // the static version of this seems to have problems... Long l = c.getLong(i); String v = l.toString(); return v; } case Cursor.FIELD_TYPE_NULL: return c.getString(i); default: case Cursor.FIELD_TYPE_BLOB: throw new IllegalStateException("Unexpected data type in SQLite table"); } }
From source file:Math.Entropy.java
private static String GetEntropyValuesCode(ArrayList<Double> values) { Double a = values.get(0); Double b = values.get(1);// w w w.jav a 2 s . c om return (a >= b) ? a.toString() + "," + b.toString() + "" : b.toString() + "," + a.toString() + ""; }
From source file:com.fpuna.preproceso.util.Util.java
public static Double calculateShannonEntropy(double valuesD[]) { Map<String, Integer> map = new HashMap<String, Integer>(); List<String> values = new ArrayList<String>(); for (Double d : valuesD) { values.add(d.toString()); }// www . java 2 s . c o m // count the occurrences of each value for (String sequence : values) { if (!map.containsKey(sequence)) { map.put(sequence, 0); } map.put(sequence, map.get(sequence) + 1); } // calculate the entropy Double result = 0.0; for (String sequence : map.keySet()) { Double frequency = (double) map.get(sequence) / values.size(); result -= frequency * (Math.log(frequency) / Math.log(2)); } return result; }
From source file:com.autentia.wuija.trace.persistence.OperationalTraceBuilder.java
public static OperationalTraceParams generateParam(String paramName, Operator operator, Double param) { return generateParam(paramName, operator, param.toString()); }
From source file:Main.java
public static Double div(Double v1, Double v2, int scale) { if (scale < 0) { throw new IllegalArgumentException("The scale must be a positive integer or zero"); }// w ww. ja va2 s .co m BigDecimal b1 = new BigDecimal(v1.toString()); BigDecimal b2 = new BigDecimal(v2.toString()); return Double.valueOf(b1.divide(b2, scale, BigDecimal.ROUND_HALF_UP).doubleValue()); }
From source file:de.cismet.lagis.cidsmigtest.StandartTypToStringTester.java
/** * DOCUMENT ME!/*from ww w. ja v a 2s . co m*/ * * @param object DOCUMENT ME! * * @return DOCUMENT ME! */ public static String getStringOf(final Double object) { if (object == null) { return null; } else { return "(Double) " + object.toString(); } }
From source file:com.hotelbeds.hotelapimodel.auto.util.AssignUtils.java
public static String getString(final Double number) { return number != null ? number.toString() : null; }
From source file:it.blogspot.geoframe.key.Key.java
private static String[] splitRealNumberIntoIntegerAndFractional(final Double value) { String tmpString = value.toString(); return tmpString.split("\\."); }
From source file:com.github.ipaas.ifw.util.IPUtil.java
/** * IP???/*from w ww .j a v a 2 s. c om*/ * * @param ip * @return */ public static long convertIpToInt(String ip) { // IP String[] ipArray = StringUtils.split(ip, '.'); // IP long ipInt = 0; // try { for (int i = 0; i < ipArray.length; i++) { if (ipArray[i] == null || ipArray[i].trim().equals("")) { ipArray[i] = "0"; } if (new Integer(ipArray[i].toString()).intValue() < 0) { Double j = new Double(Math.abs(new Integer(ipArray[i].toString()).intValue())); ipArray[i] = j.toString(); } if (new Integer(ipArray[i].toString()).intValue() > 255) { ipArray[i] = "255"; } } ipInt = new Double(ipArray[0]).longValue() * 256 * 256 * 256 + new Double(ipArray[1]).longValue() * 256 * 256 + new Double(ipArray[2]).longValue() * 256 + new Double(ipArray[3]).longValue(); // } catch (Exception e) { e.printStackTrace(); } return ipInt; }
From source file:com.aurel.track.admin.server.status.ServerStatusBL.java
private static void loadDatabaseInfo(ServerStatusTO serverStatusTO) { Connection conn = null;// ww w . j a v a2 s.co m try { conn = Torque.getConnection(BaseTSitePeer.DATABASE_NAME); DatabaseMetaData dbm = conn.getMetaData(); serverStatusTO.setDatabase(dbm.getDatabaseProductName() + " " + dbm.getDatabaseProductVersion()); serverStatusTO.setJdbcDriver(dbm.getDriverName() + " " + dbm.getDriverVersion()); serverStatusTO.setJdbcUrl(dbm.getURL()); } catch (Exception e) { LOGGER.error("Problem retrieving database meta data: " + e.getMessage()); } finally { if (conn != null) { Torque.closeConnection(conn); } } Double ping = loadPing(); serverStatusTO.setPingTime(ping.toString() + " ms"); }