Java Number Round roundUp(double val)

Here you can find the source of roundUp(double val)

Description

round Up

License

Open Source License

Declaration

public static double roundUp(double val) 

Method Source Code

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

public class Main {
    public static double roundUp(double val) {
        int exponent = (int) Math.floor(Math.log10(val));
        val *= Math.pow(10, -exponent);
        if (val > 5.0)
            val = 10.0;
        else if (val > 2.0)
            val = 5.0;
        else if (val > 1.0)
            val = 2.0;
        val *= Math.pow(10, exponent);
        return val;
    }//w ww .ja  v  a 2 s .  co m
}

Related

  1. roundUp(double a)
  2. roundUP(double d)
  3. roundUp(double d)
  4. roundUp(double n)
  5. roundUp(double n, int precision)
  6. roundUp(double val)
  7. roundUp(final double val)
  8. roundUp(final int number, final int base)
  9. RoundUp(final T number)