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

static double roundOne(double f) {
    long templ = Math.round(f * 10);
    double retd = templ / 10.0;
    return retd;/* w w w. j  a  v a2 s  .c  o  m*/
}

From source file:Main.java

private static int getRandom(int range) {
    return (int) (Math.round(range * Math.random()));
}

From source file:Main.java

public static int roundedAQI(String aqi) {
    return (int) Math.round(Double.parseDouble(aqi));
}

From source file:Main.java

public static String doubleTrans(double d) {
    if (Math.round(d) - d == 0) {
        return String.valueOf((long) d);
    }// w ww .  j a va2  s.c  o  m
    return String.valueOf(d);
}

From source file:Main.java

public static int To360Degrees(double rot) {
    return (int) Math.round(rot / Math.PI * 180);
}

From source file:Main.java

private static int ave(int s, int d, float p) {
    return s + Math.round(p * (d - s));
}

From source file:Main.java

public static float roundTwoDecimals(float f) {
    return (float) Math.round(f * 100) / 100;
}

From source file:Main.java

public static String getUserDistance(double distance) {
    return Math.round(distance / 100d) / 10d + "km";
}

From source file:Main.java

public static long bytesToSamples(long bytes, int frameSize) {
    return Math.round((float) bytes / frameSize);
}

From source file:Main.java

public static double[] mercatorToTiles(double[] e) {
    double d = Math.round((20037508.342789 + e[0]) * 53.5865938),
            f = Math.round((20037508.342789 - e[1]) * 53.5865938);
    d = boundaryRestrict(d, 0, 2147483647);
    f = boundaryRestrict(f, 0, 2147483647);
    return new double[] { d, f };
}