List of usage examples for java.lang Double intValue
public int intValue()
From source file:Main.java
public static List<Integer> doubleToIntList(List<Double> list) { List<Integer> vals = new ArrayList<>(); for (Double val : list) { vals.add(val.intValue()); }/*from w w w. j a v a 2 s . co m*/ return vals; }
From source file:Main.java
/** * Performs a division and rounds upwards to the next integer. * * @param numerator the numerator./* w w w .jav a 2s .co m*/ * @param denominator the denominator. * @return an integer value. */ public static int divideToCeil(int numerator, int denominator) { Double result = Math.ceil((double) numerator / denominator); return result.intValue(); }
From source file:Main.java
public static boolean isNan(String param) { boolean result = false; if (param == null || "".equals(param)) { return result; }//from ww w .jav a 2s. com param = param.replace('d', '_').replace('f', '_'); try { Double test = new Double(param); test.intValue(); result = true; } catch (NumberFormatException ex) { return result; } return result; }
From source file:Main.java
/** * Performs a division and rounds downwards to the next integer. * * @param numerator the numerator.//from ww w. jav a 2 s. c o m * @param denominator the denominator. * @return an integer value. */ public static int divideToFloor(int numerator, int denominator) { Double result = Math.floor((double) numerator / denominator); return result.intValue(); }
From source file:HtmlDimensions.java
public static String formatPx(Double value) { return (value.intValue() + "px"); }
From source file:org.sonar.server.computation.measure.BestValueOptimization.java
private static boolean isBestValue(Measure measure, Double bestValue) { switch (measure.getValueType()) { case BOOLEAN: return bestValue.intValue() == 1 ? measure.getBooleanValue() : !measure.getBooleanValue(); case INT:/* w w w.ja v a 2s . c om*/ return bestValue.intValue() == measure.getIntValue(); case LONG: return bestValue.longValue() == measure.getLongValue(); case DOUBLE: return bestValue.compareTo(measure.getDoubleValue()) == 0; default: return false; } }
From source file:org.xproduct.server.core.helpers.Converters.java
/** * JSON converters often convert integers to double, this converts that * double value (at the specified offset) to an integer. * * @param object object array to retrieve data * @param offset offset to retrieve data from * @return integer value//from ww w. j a v a 2s.c o m * @deprecated */ public static int getIntegerAtOffset(Object[] object, int offset) { Double dbl = ((Double) object[offset]); return dbl.intValue(); }
From source file:com.buzzcoders.yasw.widgets.map.support.GMapUtils.java
/** * Returns the type of animation given the specific value. * // w ww .j a v a 2 s . c o m * @param value value representing the marker animation * @return the animation type */ public static Animation getMarkerAnimation(Double value) { if (value != null) { switch (value.intValue()) { case 1: // google.maps.Animation.BOUNCE => 1 return Animation.BOUNCE; case 2: // google.maps.Animation.DROP => 2 return Animation.DROP; default: return null; } } return null; }
From source file:org.sonar.plugins.core.sensors.AlertUtils.java
private static Comparable<Integer> parseInteger(Alert alert, Measure measure) { Double value = getValue(alert, measure); return value != null ? value.intValue() : null; }
From source file:com.asprise.imaging.core.util.JsonUtils.java
public static Integer toInteger(Object object, Integer defaultValue) { if (object == null) { return defaultValue; }/*from w ww . jav a 2 s. co m*/ if (object instanceof Number) { return ((Number) object).intValue(); } try { Double value = Double.valueOf(object.toString().trim()); return value.intValue(); } catch (NumberFormatException e) { return defaultValue; } }