Math.round(double a) : Math « java.lang « Java by API






Math.round(double a)

  



public class MainCLass {
  public static void main(String[] args) {
    double x = 2.4;
    double y = 9.5;
    double z = -1.3;

    System.out.println("round(x) = " + Math.round(x));
    System.out.println("round(y) = " + Math.round(y));
    System.out.println("round(z) = " + Math.round(z));
    System.out.println();
    System.out.println("ceil(x) = " + Math.ceil(x));
    System.out.println("ceil(y) = " + Math.ceil(y));
    System.out.println("ceil(z) = " + Math.ceil(z));
    System.out.println();
    System.out.println("floor(x) = " + Math.floor(x));
    System.out.println("floor(y) = " + Math.floor(y));
    System.out.println("floor(z) = " + Math.floor(z));
    System.out.println();
    System.out.println("rint(x) = " + Math.rint(x));
    System.out.println("rint(y) = " + Math.rint(y));
    System.out.println("rint(z) = " + Math.rint(z));
  }
}

   
    
  








Related examples in the same category

1.Math.E
2.Math.PI
3.Math: abs(int value)
4.Math.cbrt(double a) Returns the cube root of a double value.
5.Math: ceil(float value)
6.Math: copySign(double magnitude, double sign)
7.Math: cos(double doubleValue)
8.Math: exp(double a)
9.Math: floor(float value)
10.Math: getExponent(double d)
11.Math.hypot(double x, double y) Returns sqrt(x2 +y2) without intermediate overflow or underflow.
12.Math: log(double doubleValue)
13.Math.log10(double a)
14.Math: max(int value1, int value2)
15.Math: min(double a, double b)
16.Math: min(int value1, int value2)
17.Math: nextAfter(double start, double direction)
18.Math: nextUp(double d)
19.Math: pow(int a, int b)
20.Math: random()
21.Math: scalb(double d, int scaleFactor)
22.Math.signum(float f)
23.Math: sin(double doubleValue)
24.Math.sqrt(int intValue)
25.Math: tan(double doubleValue)
26.Math: toDegrees(double theta)
27.Math: toRadians(double theta)