Java Number Round roundToNearestK(float v, int k)

Here you can find the source of roundToNearestK(float v, int k)

Description

round To Nearest K

License

Open Source License

Declaration

public static int roundToNearestK(float v, int k) 

Method Source Code

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

public class Main {
    public static int roundToNearestK(float v, int k) {
        return (int) (Math.round(v / k) * k);
    }/*from  w  ww .  j a v a 2 s. co m*/
}

Related

  1. roundToNearest(double d)
  2. roundToNearest(double number)
  3. roundToNearest(int num, int nearest)
  4. roundToNearestEven(int mantissa, int numOfBitsToRoundOff)
  5. roundToNearestInterval(int i, int j)
  6. roundToNearestMultiple(double number, double multiple)
  7. roundToNearestMultipleOf(final long num, final long multipleOf)
  8. roundToNearestN(float value, float n)
  9. roundToNearestPowerOfTen(double value)