Java Double Number Round Round(double a)

Here you can find the source of Round(double a)

Description

Floor if Value < 0.5, Ceil if Value >= 0.5

License

Creative Commons License

Declaration

public static int Round(double a) 

Method Source Code

//package com.java2s;
//License from project: Creative Commons License 

public class Main {
    /**//w  w w. j  a  va 2s .c  om
     * Floor if Value < 0.5, Ceil if Value >= 0.5
     */
    public static int Round(double a) {
        int tmp = ((int) (a * 100)) % 100;
        if (tmp < 50) {
            return Floor(a);
        } else {
            return Ceil(a);
        }
    }

    public static int Floor(double a) {
        return (int) Math.floor(a);
    }

    public static int Ceil(double a) {
        return (int) Math.ceil(a);
    }
}

Related

  1. getRatioString(double n, double d)
  2. round(double a)
  3. round(double a)
  4. round(double a, double precision)
  5. round(double a, int cutOfDigits)