List of usage examples for java.lang Double toString
public static String toString(double d)
From source file:de.tor.tribes.types.UserProfile.java
public void updateProperties() { addProperty("last.x", DSWorkbenchMainFrame.getSingleton().getCurrentPosition()[0]); addProperty("last.y", DSWorkbenchMainFrame.getSingleton().getCurrentPosition()[1]); addProperty("zoom", Double.toString(DSWorkbenchMainFrame.getSingleton().getZoomFactor())); }
From source file:com.intuit.tank.harness.functions.NumericFunctions.java
private static String subtract(String[] values, Variables variables) { Double result = null;//from w ww . j a v a 2s .co m for (int i = 3; i < values.length; i++) { if (values[i] != null) { if (result == null) { result = NumberUtils.toDouble(values[i]); } else { result -= NumberUtils.toDouble(values[i]); } } else { break; } } return Double.toString(result); }
From source file:com.link_intersystems.lang.Assert.java
/** * Assert that a double is greater than or equal to a limit. * * @param greaterOrEqual//www . jav a 2 s. c o m * the limit. * @param name * a descriptive name of the value. * @param value * the value. * * @since 1.2.0.0 */ public static void greaterOrEqual(String name, double greaterOrEqual, double value) { if (not(value >= greaterOrEqual)) { String formatted = String.format("%s must be greater than or equal to %s", name, Double.toString(greaterOrEqual)); throw new IllegalArgumentException(formatted); } }
From source file:com.wormsim.tracking.TrackedDouble.java
@Override public String toEffectiveDataCountString() { return Double.toString(this.getEffectiveDataCount()); }
From source file:org.apache.archiva.redback.tests.AbstractRbacManagerPerformanceTestCase.java
public void assertPerformance(String msg, long startTime, long endTime, int iterations, double threshold) { long elapsed = endTime - startTime; double ratio = (double) elapsed / (double) ONESECOND; // ratio of time to 1 second. double opsPerSecond = (double) iterations / ratio; logger.info("Performance {}: {} operations per second. (effective)", msg, opsPerSecond); if (opsPerSecond < threshold) { // Failure StringBuilder stats = new StringBuilder(); stats.append("Stats on ").append(msg); stats.append("\nStart Time (ms): ").append(Long.toString(startTime)); stats.append("\nEnd Time (ms) : ").append(Long.toString(endTime)); stats.append("\nElapsed (ms) : ").append(Long.toString(elapsed)); stats.append("\nRatio : ").append(Double.toString(ratio)); stats.append("\nOps per second : ").append(Double.toString(opsPerSecond)); logger.info(stats.toString());//from ww w .ja va 2s .c o m fail("Performance Error: " + msg + " expecting greater than [" + threshold + "], actual [" + opsPerSecond + "]"); } }
From source file:com.wesley.urban_cuts.client.urbancuts.myFrame.java
/** * Creates new form HomeFrame// w w w .j a v a 2 s. c om */ public myFrame() { initComponents(); ctx = new ClassPathXmlApplicationContext( "classpath:com/wesley/urban_cuts/app/conf/applicationContext-*.xml"); staffCrudService = (StaffCrudService) ctx.getBean("StaffCrudService"); styleCrudService = (StyleCrudService) ctx.getBean("StyleCrudService"); paymentCrudService = (PaymentCrudService) ctx.getBean("PaymentCrudService"); populate_barbers(); populate_styles(); populate_table(); jList2.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent event) { if (!event.getValueIsAdjusting()) { JList source = (JList) event.getSource(); String selected = source.getSelectedValue().toString(); jTextField1.setText(selected); } } }); jList3.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent event) { if (!event.getValueIsAdjusting()) { JList source = (JList) event.getSource(); String selected2 = source.getSelectedValue().toString(); jTextField3.setText(selected2); Style s = styleCrudService.getByPropertyName("style_name", jTextField3.getText()); jTextField2.setText(Double.toString(s.getPrice())); } } }); }
From source file:edu.cmu.tetrad.calculator.expression.ConstantExpression.java
public String toString() { if (name == null) { return Double.toString(value); } else { return name; } }
From source file:desmoj.core.dist.ContDistGamma.java
/** * Returns the next sample from this distribution. The value depends upon * the seed, the number of values taken from the stream by using this method * before and the alpha and beta parameters specified for this distribution. * //from w w w . j ava2 s. c o m * @return Double : The next gamma distributed sample from this * distribution. */ public Double sample() { double newSample = -1; // double randomNumber = randomGenerator.nextDouble(); org.apache.commons.math.distribution.GammaDistribution gammadist = new org.apache.commons.math.distribution.GammaDistributionImpl( alpha, beta); incrementObservations(); // increase count of samples if (isAntithetic()) { try { newSample = gammadist.inverseCumulativeProbability(1 - randomNumber); } catch (MathException e) { } } else { try { newSample = gammadist.inverseCumulativeProbability(randomNumber); } catch (MathException e) { } } if (this.currentlySendTraceNotes()) this.traceLastSample(Double.toString(newSample)); return newSample; }
From source file:com.ibm.mds.MobileServlet.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String question = req.getParameter("questionText"); if (question == null || question.trim().equals("")) { doResp(formartErrJsonMsg(RESP_ERR_COMMAND_NOT_CORRECT, RESP_TXT_COMMAND_NOT_CORRECT), resp); return;/*from ww w .ja v a2 s . c om*/ } // create the { 'question' : { // 'questionText:'...', // 'evidenceRequest': { 'items': 5} } json as requested by the service JSONObject questionJson = new JSONObject(); questionJson.put("questionText", question); JSONObject evidenceRequest = new JSONObject(); evidenceRequest.put("items", 5); questionJson.put("evidenceRequest", evidenceRequest); JSONObject postData = new JSONObject(); postData.put("question", questionJson); try { Executor executor = Executor.newInstance().auth(username, password); URI serviceURI = new URI(baseURL + "/v1/question/travel").normalize(); String answersJsonStr = executor .execute(Request.Post(serviceURI).addHeader("Accept", "application/json") .addHeader("X-SyncTimeout", "30") .bodyString(postData.toString(), ContentType.APPLICATION_JSON)) .returnContent().asString(); JSONObject resultObject = new JSONObject(); JSONArray jsonArray = new JSONArray(); JSONArray pipelines = JSONArray.parse(answersJsonStr); // the response has two pipelines, lets use the first one JSONObject answersJson = (JSONObject) pipelines.get(0); JSONArray answers = (JSONArray) ((JSONObject) answersJson.get("question")).get("evidencelist"); for (int i = 0; i < answers.size(); i++) { JSONObject answer = (JSONObject) answers.get(i); double p = Double.parseDouble((String) answer.get("value")); p = Math.floor(p * 100); JSONObject obj = new JSONObject(); obj.put("confidence", Double.toString(p) + "%"); obj.put("text", (String) answer.get("text")); jsonArray.add(obj); } resultObject.put("respCode", RESP_SUCCESS); resultObject.put("body", jsonArray); doResp(resultObject.toString(), resp); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.isencia.passerelle.message.type.ComplexConverter.java
protected Object convertTokenToContent(Token typedToken, Class targetType) throws MessageException { Complex cVal = ((ComplexToken) typedToken).complexValue(); if (targetType != null && !Complex.class.equals(targetType)) { if (String.class.equals(targetType)) { return cVal.toString(); } else {//w w w .j a v a 2 s .co m // only take real part try { Constructor c = targetType.getConstructor(new Class[] { String.class }); return c.newInstance(new Object[] { Double.toString(cVal.real) }); } catch (Exception e) { throw new UnsupportedOperationException(); } } } else { // we just return a Complex as default, // if no specific target type is given try { double real = cVal.real; double imag = cVal.imag; return new Complex(real, imag); } catch (ClassCastException e) { throw new UnsupportedOperationException(); } } }