List of usage examples for java.lang Double Double
@Deprecated(since = "9") public Double(String s) throws NumberFormatException
From source file:gradingfun.GradeParser.java
public void parse() { Map<String, Double> data = new HashMap<String, Double>(); for (CSVRecord csvRecord : this.parser) { if (csvRecord.getRecordNumber() > 1) { String lastName = csvRecord.get(0); String firstName = csvRecord.get(1); String score = csvRecord.get(6); Double dblScore = null; try { dblScore = new Double(score); } catch (NumberFormatException ex) { dblScore = 0.0;//from ww w .j ava2s . co m } data.put(firstName + " " + lastName, dblScore); } } this.parsedData = data; try { this.parser.close(); } catch (IOException ex) { Logger.getLogger(GradeParser.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:Main.java
private JFormattedTextField setFormat(JFormattedTextField jft, Locale local1, int minFra, int maxFra) { NumberFormat numberFormat;//w ww. ja v a 2s. co m Locale local = local1; int setMin = minFra; int setMax = maxFra; numberFormat = NumberFormat.getCurrencyInstance(local); numberFormat.setMinimumFractionDigits(setMin); numberFormat.setMaximumFractionDigits(setMax); numberFormat.setRoundingMode(RoundingMode.HALF_UP); jft = new JFormattedTextField(numberFormat); jft.setValue(new Double(342.796)); return jft; }
From source file:com.datamyne.charts.AlmostThereDemo.java
/** * Gets a {@link JFreeChart}./* w ww. j av a2 s.c o m*/ * @return {@link JFreeChart}. */ public JFreeChart getChart() { //create dummy data //taken from http://www.java2s.com/Code/Java/Chart/JFreeChartPieChartDemo1.htm DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("One", new Double(43.2)); dataset.setValue("Two", new Double(10.0)); dataset.setValue("Three", new Double(27.5)); dataset.setValue("Four", new Double(17.5)); dataset.setValue("Five", new Double(11.0)); dataset.setValue("Six", new Double(19.4)); //use the ChartFactory to create a pie chart JFreeChart chart = ChartFactory.createPieChart("Dummy Data", dataset, true, true, false); return chart; }
From source file:com.clust4j.utils.MatrixFormatter.java
static Object[] doubleToObj(double[] d) { final Object[] o = new Object[d.length]; for (int i = 0; i < o.length; i++) o[i] = (Object) new Double(d[i]); return o;//from w ww .j a v a 2 s. c o m }
From source file:com.processpuzzle.fundamental_types.domain.ParameterValue.java
public static ParameterValue parse(String definitionText) throws ClassNotFoundException, InstantiationException, IllegalAccessException { ParameterDefinition definition = ParameterDefinition.parse(definitionText); Pattern valuePattern = Pattern.compile("=([^/]+)/{0,2}"); Matcher valueFinder = valuePattern.matcher(definitionText); String valueString = null;//from www . j a va2 s. c o m if (valueFinder.find()) { int valueStringLength = valueFinder.group().contains("//") ? valueFinder.group().length() - 2 : valueFinder.group().length(); valueString = StringUtils.strip(valueFinder.group().substring(1, valueStringLength)); } Object valueObject = null; if (definition.getType().equals(String.class)) valueObject = new String(valueString); else if (definition.getType().equals(Integer.class)) valueObject = new Integer(valueString); else if (definition.getType().equals(Long.class)) valueObject = new Long(valueString); else if (definition.getType().equals(Double.class)) valueObject = new Double(valueString); return new ParameterValue(definition, valueObject); }
From source file:com.joptimizer.algebra.ComparisonTest.java
public void testSparseMatrix1() throws Exception { log.debug("testSparseMatrix1"); int rows = 750; int cols = 750; int dim = rows * cols; DoubleMatrix2D sMatrix = Utils.randomValuesSparseMatrix(rows, cols, -5, 5, 0.50, 12345L); //log.debug("sMatrix: " + Utils.toString(sMatrix.toArray())); log.debug("cardinality: " + sMatrix.cardinality()); int nz = dim - sMatrix.cardinality(); log.debug("sparsity index: " + 100 * new Double(nz) / dim + " %"); //try sparse multiplication long t0 = System.currentTimeMillis(); Algebra.DEFAULT.mult(sMatrix, sMatrix); log.debug("sparse time: " + (System.currentTimeMillis() - t0)); //try RC sparse multiplication DoubleMatrix2D rcMatrix = new RCDoubleMatrix2D(sMatrix.toArray()); long t1 = System.currentTimeMillis(); // // Linear algebraic y = A * x // DoubleMatrix2D Y = new RCDoubleMatrix2D(rows, cols); // rcMatrix.forEachNonZero( // new cern.colt.function.IntIntDoubleFunction() { // public double apply(int row, int column, double value) { // T.setQuick(row, Y.getQuick(row) + value * x.getQuick(column)); // return value; // } // }//from w ww .j a va2s . c om // ); Algebra.DEFAULT.mult(rcMatrix, rcMatrix); log.debug("rc time: " + (System.currentTimeMillis() - t1)); //try dense multiplication DoubleMatrix2D dMatrix = DoubleFactory2D.dense.make(sMatrix.toArray()); long t2 = System.currentTimeMillis(); Algebra.DEFAULT.mult(dMatrix, dMatrix); log.debug("dense time: " + (System.currentTimeMillis() - t2)); }
From source file:AIR.Common.Configuration.AppSettings.java
public static AppSetting<Double> getDouble(String name) { return AppSettings.<Double>get(name, new Double(0), new AppSettingsHelperMethodWrapper<Double>() { @Override//from www . j a va2s . c o m public Double getValue(String key, Double defaultValue) { return AppSettingsHelper.getDouble(key, defaultValue); } }); }
From source file:jp.co.acroquest.endosnipe.report.converter.util.calc.DoubleCalculator.java
public Object mul(Object obj1, Object obj2) { Double doubleData1 = (Double) obj1; Double doubleData2 = (Double) obj2; return (Object) (new Double((double) (doubleData1.doubleValue() * doubleData2.doubleValue()))); }
From source file:NumberFormatDemo.java
static public void displayPercent(Locale currentLocale) { Double percent = new Double(0.75); NumberFormat percentFormatter; String percentOut;/*from w w w .j a va 2s. c o m*/ percentFormatter = NumberFormat.getPercentInstance(currentLocale); percentOut = percentFormatter.format(percent); System.out.println(percentOut + " " + currentLocale.toString()); }
From source file:org.obp.web.DefaultsController.java
@RequestMapping("/secure/defaults/update") public ResponseEntity updateDefaultValue(@RequestParam String name, @RequestParam String value) { try {// www . j ava 2 s . c o m defaultDataInstrument.updateReadout(name, new Double(value)); } catch (Exception e) { return new ResponseEntity(HttpStatus.BAD_REQUEST); } return new ResponseEntity(HttpStatus.OK); }