List of usage examples for java.lang Math floor
public static double floor(double a)
From source file:Main.java
/** * * @param d eot in hours//from w w w .java 2 s .co m * @return formatted string */ public final static String eotToString(double d) { int m = (int) Math.floor(Math.abs(d) * 60d); int s = (int) Math.round((3600d * Math.abs(d)) - (m * 60d)); return ((d > 0 ? "+" : "-") + Integer.toString(m) + "m" + Integer.toString(s) + "s"); }
From source file:Main.java
public static String kgToLB_ForBodyScale(float paramFloat) { int i = (int) Math.floor(1.0F + (32768.0F + 144479.0F * (paramFloat * 10.0F)) / 65536.0F); if (i % 2 != 0) { i--;//from ww w .j a v a 2s . c o m } DecimalFormat localDecimalFormat = new DecimalFormat(); localDecimalFormat.setMaximumFractionDigits(1); localDecimalFormat.setGroupingSize(0); localDecimalFormat.setRoundingMode(RoundingMode.FLOOR); return localDecimalFormat.format(0.1D * i); }
From source file:Main.java
public static double getOverDifference(Double startOvers, Double endOvers) { Double startOvers1 = Math.floor(startOvers); Double startOvers2 = startOvers - startOvers1; Double endOvers1 = Math.floor(endOvers); Double endOvers2 = endOvers - endOvers1; Double diff1 = startOvers1 - endOvers1; Double diff2 = startOvers2 - endOvers2; if (diff2 < 0) { diff1 -= 0.4; // for eg 12 becomes 11.6 }//w w w .ja v a 2 s .c o m diff1 += diff2; return diff1; }
From source file:Main.java
public static Double roundDouble(double val, int precision) { Double ret = null;/*w w w.j av a2 s. co m*/ try { double factor = Math.pow(10, precision); ret = Math.floor(val * factor + 0.5) / factor; } catch (Exception e) { e.printStackTrace(); } return ret; }
From source file:Main.java
public static String fromSecondsToMMSS(int seconds) throws Exception { if (seconds > 3600) throw new Exception("more than an hour"); int m = (int) Math.floor(seconds / 60); int s = seconds - (m * 60); String mm = m > 0 ? String.format("%2d", m) + ":" : ""; String ss = m > 0 ? String.format("%02d", s) : String.format("%2d", s); return mm + ss; }
From source file:Main.java
public static float round(final float value, final float share) { return (float) Math.floor(value * share) / share; }
From source file:Main.java
/** * Converts a double to a value between 0 and 360 * //from w w w. j av a 2 s. c o m * @param x * @return double in 0-360 range */ public static float floatrev(double x) { return (float) (x - Math.floor(x / 360.0f) * 360.0f); }
From source file:Main.java
public static String transferAVG_RTT(String oldValue) { String newValue = oldValue;/* w w w . ja v a2s . c om*/ float ov = Float.valueOf(oldValue); newValue = String.valueOf(Math.floor(ov + 0.5)); return newValue; }
From source file:Main.java
public static int calcyseal(int bthyear) { int abs = (Math.abs(1965 - bthyear)); y = abs / 4.00;/*from w w w .j a v a2 s . c o m*/ y = y - Math.floor(y); if (y > 0) { cont = calcyseal(bthyear + 1); return (cont + 1); } else return (1); }
From source file:Main.java
/** * Rounds off downwards to the next distinct value. * * @param value The value to round off//from w w w . j a v a 2 s .co m * @return The rounded value */ public static double getFloor(double value) { return Math.floor(value); }