Java Number Round roundToNearest(double number)

Here you can find the source of roundToNearest(double number)

Description

round To Nearest

License

Open Source License

Declaration

public static double roundToNearest(double number) 

Method Source Code

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

public class Main {
    public static double roundToNearest(double number) {
        if ((int) (number + .5) >= (int) (number))
            return (int) number + 1;
        return (int) number;
    }/*from   w w w. j a v a 2 s .  co  m*/
}

Related

  1. roundToMultipleXLength(int inLength, int multipler)
  2. roundToN(double d, int n)
  3. roundToNDecimalPlaces(final double in, final int n)
  4. roundToNDigits(double d, int n)
  5. roundToNearest(double d)
  6. roundToNearest(int num, int nearest)
  7. roundToNearestEven(int mantissa, int numOfBitsToRoundOff)
  8. roundToNearestInterval(int i, int j)
  9. roundToNearestK(float v, int k)