List of usage examples for java.lang Integer floatValue
public float floatValue()
From source file:Main.java
public static void main(String[] args) { Integer integerObject = new Integer("1234567"); float f = integerObject.floatValue(); System.out.println("float" + f); }
From source file:Main.java
public static void main(String[] args) { Integer intObj = new Integer("10"); byte b = intObj.byteValue(); System.out.println(b);/* w w w .j a v a 2 s . c o m*/ short s = intObj.shortValue(); System.out.println(s); int i = intObj.intValue(); System.out.println(i); float f = intObj.floatValue(); System.out.println(f); double d = intObj.doubleValue(); System.out.println(d); }
From source file:com.ms.app.web.commons.tools.CurrencyFormattor.java
/** * 100? ??// w w w. jav a 2 s . c o m */ public static Float formatScore(Integer score) { if (score == null) { return null; } return score.floatValue() / 100; }
From source file:com.github.jessemull.microflex.util.IntegerUtil.java
/** * Converts a list of integers to a list of floats. * @param List<Integer> list of integers * @return list of floats *///from ww w . j a v a2 s . c o m public static List<Float> toFloatList(List<Integer> list) { List<Float> floatList = new ArrayList<Float>(); for (Integer val : list) { floatList.add(val.floatValue()); } return floatList; }
From source file:com.griddynamics.jagger.engine.e1.scenario.DefaultWorkloadSuggestionMaker.java
private static Integer findClosestPoint(BigDecimal desiredTps, Map<Integer, Pair<Long, BigDecimal>> stats) { final int MAX_POINTS_FOR_REGRESSION = 10; SortedMap<Long, Integer> map = Maps.newTreeMap(new Comparator<Long>() { @Override//w w w . j a v a 2s . c o m public int compare(Long first, Long second) { return second.compareTo(first); } }); for (Map.Entry<Integer, Pair<Long, BigDecimal>> entry : stats.entrySet()) { map.put(entry.getValue().getFirst(), entry.getKey()); } if (map.size() < 2) { throw new IllegalArgumentException("Not enough stats to calculate point"); } // <time><number of threads> - sorted by time Iterator<Map.Entry<Long, Integer>> iterator = map.entrySet().iterator(); SimpleRegression regression = new SimpleRegression(); Integer tempIndex; double previousValue = -1.0; double value; double measuredTps; log.debug("Selecting next point for balancing"); int indx = 0; while (iterator.hasNext()) { tempIndex = iterator.next().getValue(); if (previousValue < 0.0) { previousValue = tempIndex.floatValue(); } value = tempIndex.floatValue(); measuredTps = stats.get(tempIndex).getSecond().floatValue(); regression.addData(value, measuredTps); log.debug(String.format(" %7.2f %7.2f", value, measuredTps)); indx++; if (indx > MAX_POINTS_FOR_REGRESSION) { break; } } double intercept = regression.getIntercept(); double slope = regression.getSlope(); double approxPoint; // if no slope => use previous number of threads if (Math.abs(slope) > 1e-12) { approxPoint = (desiredTps.doubleValue() - intercept) / slope; } else { approxPoint = previousValue; } // if approximation point is negative - ignore it if (approxPoint < 0) { approxPoint = previousValue; } log.debug(String.format("Next point %7d (target tps: %7.2f)", (int) Math.round(approxPoint), desiredTps.doubleValue())); return (int) Math.round(approxPoint); }
From source file:org.apache.hadoop.hive.ql.udf.UDFToFloat.java
public Float evaluate(Integer i) { if (i == null) { return null; } else {//from w w w . j a va2 s . c o m return Float.valueOf(i.floatValue()); } }
From source file:de.frank_durr.ble_v_monitor.HistoryFragment.java
/** * Update the view data according to the data stored by the data model. *///from w w w.java2 s . co m private void updateView() { List<Integer> historyData = null; String label = null; String timeUnitStr = null; switch (historyType) { case minutely: historyData = DataModel.theModel.getMinutelyHistory(); label = getResources().getString(R.string.minutely_history); timeUnitStr = "min"; break; case hourly: historyData = DataModel.theModel.getHourlyHistory(); label = getResources().getString(R.string.hourly_history); timeUnitStr = "h"; break; case daily: historyData = DataModel.theModel.getDailyHistory(); label = getResources().getString(R.string.daily_history); timeUnitStr = "d"; break; } if (historyData == null) { // No history data in data model return; } ArrayList<Entry> values = new ArrayList<>(); int x = 0; for (Integer value : historyData) { float v = (float) (value.floatValue() / 1000.0); Entry entry = new Entry(v, x++); values.add(entry); } LineDataSet dataSet = new LineDataSet(values, label); dataSet.setLineWidth(2.5f); dataSet.setCircleSize(4.5f); dataSet.setColor(Color.rgb(255, 0, 0)); dataSet.setCircleColor(Color.rgb(255, 0, 0)); dataSet.setHighLightColor(Color.rgb(255, 0, 0)); dataSet.setAxisDependency(YAxis.AxisDependency.LEFT); dataSet.setDrawValues(false); //dataSet.setValueTextSize(10f); ArrayList<LineDataSet> dataSets = new ArrayList<>(); dataSets.add(dataSet); int xValueCnt = historyData.size(); ArrayList<String> xVals = new ArrayList<>(); for (int i = 0; i < xValueCnt; i++) { xVals.add(Integer.toString(-xValueCnt + i + 1) + timeUnitStr); } LineData data = new LineData(xVals, dataSets); chart.setDescription(""); // Refresh chart chart.setData(data); chart.notifyDataSetChanged(); chart.invalidate(); }
From source file:net.sourceforge.msscodefactory.cflib.v1_11.CFLib.Swing.CFJFloatEditor.java
public boolean isEditValid() { final String S_ProcName = "isEditValid"; if (!hasValue()) { setValue(null);// w w w . j a va 2s . com return (true); } boolean retval = super.isEditValid(); if (retval) { try { commitEdit(); } catch (ParseException e) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Field is not valid - " + e.getMessage(), e); } Object obj = getValue(); if (obj == null) { retval = false; } else if (obj instanceof Float) { Float v = (Float) obj; Float min = getMinValue(); Float max = getMaxValue(); if ((v.compareTo(min) < 0) || (v.compareTo(max) > 0)) { retval = false; } } else if (obj instanceof Double) { Double v = (Double) obj; Double min = getMinValue().doubleValue(); Double max = getMaxValue().doubleValue(); if ((v.compareTo(min) < 0) || (v.compareTo(max) > 0)) { retval = false; } } else if (obj instanceof Short) { Short s = (Short) obj; Float v = new Float(s.floatValue()); Float min = getMinValue(); Float max = getMaxValue(); if ((v.compareTo(min) < 0) || (v.compareTo(max) > 0)) { retval = false; } } else if (obj instanceof Integer) { Integer i = (Integer) obj; Float v = new Float(i.floatValue()); Float min = getMinValue(); Float max = getMaxValue(); if ((v.compareTo(min) < 0) || (v.compareTo(max) > 0)) { retval = false; } } else if (obj instanceof Long) { Long l = (Long) obj; Float v = new Float(l.floatValue()); Float min = getMinValue(); Float max = getMaxValue(); if ((v.compareTo(min) < 0) || (v.compareTo(max) > 0)) { retval = false; } } else if (obj instanceof BigDecimal) { BigDecimal b = (BigDecimal) obj; Float v = new Float(b.toString()); Float min = getMinValue(); Float max = getMaxValue(); if ((v.compareTo(min) < 0) || (v.compareTo(max) > 0)) { retval = false; } } else if (obj instanceof Number) { Number n = (Number) obj; Float v = new Float(n.toString()); Float min = getMinValue(); Float max = getMaxValue(); if ((v.compareTo(min) < 0) || (v.compareTo(max) > 0)) { retval = false; } } else { throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), S_ProcName, "EditedValue", obj, "Short, Integer, Long, BigDecimal, Float, Double or Number"); } } return (retval); }
From source file:net.sourceforge.msscodefactory.cflib.v1_11.CFLib.Swing.CFJFloatEditor.java
public Float getFloatValue() { final String S_ProcName = "getFloatValue"; Float retval;//from w w w . jav a 2 s. c o m String text = getText(); if ((text == null) || (text.length() <= 0)) { retval = null; } else { if (!isEditValid()) { throw CFLib.getDefaultExceptionFactory().newInvalidArgumentException(getClass(), S_ProcName, "Field is not valid"); } try { commitEdit(); } catch (ParseException e) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Field is not valid - " + e.getMessage(), e); } Object obj = getValue(); if (obj == null) { retval = null; } else if (obj instanceof Float) { Float v = (Float) obj; Float min = getMinValue(); Float max = getMaxValue(); if ((v.compareTo(min) < 0) || (v.compareTo(max) > 0)) { throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0, "EditedValue", v, min, max); } retval = v; } else if (obj instanceof Double) { Double v = (Double) obj; Double min = getMinValue().doubleValue(); Double max = getMaxValue().doubleValue(); if ((v.compareTo(min) < 0) || (v.compareTo(max) > 0)) { throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0, "EditedValue", v, min, max); } retval = new Float(v.floatValue()); } else if (obj instanceof Short) { Short s = (Short) obj; Float v = new Float(s.floatValue()); Float min = getMinValue(); Float max = getMaxValue(); if ((v.compareTo(min) < 0) || (v.compareTo(max) > 0)) { throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0, "EditedValue", v, min, max); } retval = v; } else if (obj instanceof Integer) { Integer i = (Integer) obj; Float v = new Float(i.floatValue()); Float min = getMinValue(); Float max = getMaxValue(); if ((v.compareTo(min) < 0) || (v.compareTo(max) > 0)) { throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0, "EditedValue", v, min, max); } retval = v; } else if (obj instanceof Long) { Long l = (Long) obj; Float v = new Float(l.floatValue()); Float min = getMinValue(); Float max = getMaxValue(); if ((v.compareTo(min) < 0) || (v.compareTo(max) > 0)) { throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0, "EditedValue", v, min, max); } retval = v; } else if (obj instanceof BigDecimal) { BigDecimal b = (BigDecimal) obj; Float v = new Float(b.toString()); Float min = getMinValue(); Float max = getMaxValue(); if ((v.compareTo(min) < 0) || (v.compareTo(max) > 0)) { throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0, "EditedValue", v, min, max); } retval = v; } else if (obj instanceof Number) { Number n = (Number) obj; Float v = new Float(n.toString()); Float min = getMinValue(); Float max = getMaxValue(); if ((v.compareTo(min) < 0) || (v.compareTo(max) > 0)) { throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0, "EditedValue", v, min, max); } retval = v; } else { throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), S_ProcName, "EditedValue", obj, "Short, Integer, Long, BigDecimal or Number"); } } return (retval); }
From source file:com.sms.server.service.AdaptiveStreamingService.java
public List<String> generateHLSPlaylist(long id, String baseUrl) { List<String> playlist = new ArrayList<>(); Job job = jobDao.getJobByID(id);/*from w w w .j a va2s . com*/ if (job == null) { return null; } MediaElement mediaElement = mediaDao.getMediaElementByID(job.getMediaElement()); if (mediaElement == null) { return null; } playlist.add("#EXTM3U"); playlist.add("#EXT-X-VERSION:3"); playlist.add("#EXT-X-TARGETDURATION:" + HLSTranscode.DEFAULT_SEGMENT_DURATION); playlist.add("#EXT-X-ALLOW-CACHE:YES"); playlist.add("#EXT-X-MEDIA-SEQUENCE:0"); playlist.add("#EXT-X-PLAYLIST-TYPE:VOD"); // Get Video Segments for (int i = 0; i < (mediaElement.getDuration() / HLSTranscode.DEFAULT_SEGMENT_DURATION); i++) { playlist.add("#EXTINF:" + HLSTranscode.DEFAULT_SEGMENT_DURATION.floatValue() + ","); playlist.add(createHLSSegmentUrl(baseUrl, job.getID(), i)); } // Determine the duration of the final segment. Integer remainder = mediaElement.getDuration() % HLSTranscode.DEFAULT_SEGMENT_DURATION; if (remainder > 0) { playlist.add("#EXTINF:" + remainder.floatValue() + ","); playlist.add(createHLSSegmentUrl(baseUrl, job.getID(), mediaElement.getDuration() / HLSTranscode.DEFAULT_SEGMENT_DURATION)); } playlist.add("#EXT-X-ENDLIST"); return playlist; }