Java Number Round round(Number number, Number unit)

Here you can find the source of round(Number number, Number unit)

Description

round

License

Open Source License

Declaration

public static Number round(Number number, Number unit) 

Method Source Code

//package com.java2s;

public class Main {
    public static Number round(Number number, Number unit) {
        double n = number.doubleValue();
        double u = unit.doubleValue();

        double r = Math.IEEEremainder(n, u);

        if (r < n / 2) {
            n -= r;/*from w w w  .j  a va2s  . c  o m*/
        } else {
            n = n + u - r;
        }

        return new Double(n);

    }
}

Related

  1. round(int start, int boundary)
  2. round(int t, int n, int decimals)
  3. round(int top, int div2, int divisor)
  4. round(int x, int quantum)
  5. round(Integer a)
  6. Round(Object in)
  7. round(String num, int length)
  8. round4(int n)
  9. round_pow2(int x)