Java Number Round roundUpDown(int number, int by)

Here you can find the source of roundUpDown(int number, int by)

Description

round Up Down

License

Open Source License

Declaration

public static int roundUpDown(int number, int by) 

Method Source Code

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

public class Main {
    public static int roundUpDown(int number, int by) {
        int result = number;
        if (by > 0) {
            result = number + (by - number % by);
        } else if (by < 0) {
            if (number % by == 0) {
                number--;/*from   w ww.j a  v a  2  s  .c  o m*/
                result = number - number % by;
            } else {
                result = number - number % by;
            }
        } else {
            return result;
        }
        return result;
    }
}

Related

  1. roundUp(long position, long sectionAlignment)
  2. roundUp(long size, int blockSize)
  3. roundUp(long val, long delta)
  4. roundup_2n(long val, int blocksize)
  5. roundUpDivision(final int dividend, final int divider)
  6. roundUpIfNecessary(long timeout, long convertedTimeout)
  7. roundUpLong(long value, long interval)
  8. roundUpLong(long x, long blockSizePowerOf2)
  9. roundUpNumberByUsingMultipleValue(double number, double multiple)