Java Double Number Round round(double num, int bit)

Here you can find the source of round(double num, int bit)

Description

round

License

Open Source License

Declaration

public static double round(double num, int bit) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static double round(double num, int bit) {
        int t = 10;
        for (int i = 0; i < bit; i++)
            t *= 10;/* w  ww .  ja va2s  . co m*/
        double n = num * t;
        if (5 <= (n % 10))
            n += 10;
        return (double) ((int) n / 10) / (t / 10);
    }

    public static double round(double num) {
        return round(num, 0);
    }
}

Related

  1. round(double input, double step)
  2. round(double n)
  3. round(double n, double nd)
  4. round(Double num)
  5. round(double num)
  6. round(double num, int decimal)
  7. round(double num, int numDecs, boolean rawFactor)
  8. round(double num, int precision)
  9. round(double number)