List of usage examples for java.lang Math round
public static long round(double a)
From source file:Main.java
public static double roundFraction(Double value, int precision) { int scale = (int) Math.pow(10, precision); return (double) Math.round(value * scale) / scale; }
From source file:Main.java
public static int convertDpToPixel(Context context, int dp) { float density = context.getResources().getDisplayMetrics().density; return Math.round((float) dp * density); }
From source file:Main.java
public static String fileSizeFormat(long size) { float mbSize = size / 1000f / 1000f; if (mbSize < 1000f) { return String.format("%d MB ", Math.round(mbSize)); } else {//from w w w . j a va 2 s. com float gSize = mbSize / 1000f; if (gSize < 1000f) { return String.format("%d G ", Math.round(gSize)); } else { float TSize = gSize / 1000f; return String.format("%d T ", Math.round(TSize)); } } }
From source file:Main.java
/** * //from w w w.j a v a2s. c om * @param variation * @return */ public static String makeVariation(double variation) { int var = (int) Math.round(variation); String ret = String.format(Locale.getDefault(), "%02d", var); if (var < 0) { ret = "E" + var + "\u00B0 "; } else { ret = "W" + var + "\u00B0 "; } return ret; }
From source file:Main.java
public static int formatPix(Context context, float pixValue) { int width = 640; return (int) Math.round(getScreenWidth(context) * 1.0 / width * pixValue); }
From source file:Main.java
public static int formatPix(Context context, float pixValue) { int width = 720; return (int) Math.round(getScreenWidth(context) * 1.0 / width * pixValue); }
From source file:Main.java
public static int cmToDpi(float size, DisplayMetrics metrics) { float totalDIP = metrics.densityDpi; float inches = size / 25.4f; return Math.round(inches * totalDIP); }
From source file:Main.java
public static int calcPercent(final int value, final int percent) { final float p = (float) percent; final float p100 = p / 100; return Math.round(value * p100); }
From source file:Main.java
public static int adjustAlpha(int color, @SuppressWarnings("SameParameterValue") float factor) { int alpha = Math.round(Color.alpha(color) * factor); int red = Color.red(color); int green = Color.green(color); int blue = Color.blue(color); return Color.argb(alpha, red, green, blue); }
From source file:Main.java
public static int totalGrade(float totalMiles, float penaltyPoint) { float safetyPoint = totalMiles + penaltyPoint; float totalGrade = (safetyPoint / totalMiles) * 100; return Math.round(totalGrade); }