Example usage for java.lang Math round

List of usage examples for java.lang Math round

Introduction

In this page you can find the example usage for java.lang Math round.

Prototype

public static long round(double a) 

Source Link

Document

Returns the closest long to the argument, with ties rounding to positive infinity.

Usage

From source file:Main.java

private static double roundDoubleToDecimal(double d) {

    d = d * 10;/*from   www  . j av a  2  s .  co m*/
    int i = (int) Math.round(d);
    d = (double) i / 10;

    return d;
}

From source file:Main.java

public static String getDistanciaConFormato(float distancia) {

    String distanciaString = Math.round(distancia) + " metros";
    if (distancia >= 1000f) {
        distanciaString = Math.round(distancia / 1000f) + "km";
    }/*from   w w  w  . j a  v a 2s  .  c  om*/

    return distanciaString;
}

From source file:Main.java

private static double UFr(double paramDouble) {
    return Math.round(paramDouble);
}

From source file:Main.java

public static double roundOffToTwoDecimal(double valueDouble) {

    double roundOff = (double) Math.round(valueDouble * 100) / 100;
    return roundOff;
}

From source file:Main.java

public static float scaleNumber(float num, int bit) {
    int range = 10 * bit;
    return (float) Math.round(num * range) / range;
}

From source file:Main.java

private static long toSourceCoords(double value, int inSampleSize, long max) {
    long result = Math.round(value * inSampleSize);
    if (result <= 0)
        return 0;
    if (result >= max)
        return max;
    return result;
}

From source file:Main.java

public static int randomColor() {
    return Color.argb(127, ((Long) Math.round(Math.random() * 255)).intValue(),
            ((Long) Math.round(Math.random() * 255)).intValue(),
            ((Long) Math.round(Math.random() * 255)).intValue());
}

From source file:Main.java

private static long fromSourceCoords(double value, int inSampleSize, long max) {
    long result = Math.round(value / inSampleSize);
    if (result <= 0)
        return 0;
    if (result >= max)
        return max;
    return result;
}

From source file:Main.java

public static float myround(float paramFloat) {
    return (float) (Math.round(10.0F * paramFloat) / 10.0D);
}

From source file:Main.java

public static int adjustAlphaColor(int i, float f) {
    return Color.argb(Math.round((float) Color.alpha(i) * f), Color.red(i), Color.green(i), Color.blue(i));
}