Java Number Round round_up(int value, int multiple)

Here you can find the source of round_up(int value, int multiple)

Description

Round a number up to a given multiple.

License

Open Source License

Parameter

Parameter Description
value the number to be rounded
multiple the number to which to be rounded

Return

the smallest int greater than or equal to value which divides multiple exactly.

Declaration

public static int round_up(int value, int multiple) 

Method Source Code

//package com.java2s;
/*/*from  w w w . j  av  a  2s.co m*/
 * JGrass - Free Open Source Java GIS http://www.jgrass.org 
 * (C) HydroloGIS - www.hydrologis.com 
 * 
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Library General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your option) any
 * later version.
 * 
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU Library General Public License
 * along with this library; if not, write to the Free Foundation, Inc., 59
 * Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

public class Main {
    /**
     * Round a number up to a given multiple.
     *
     * @param value the number to be rounded
     * @param multiple the number to which to be rounded
     *
     * @return the smallest <code>int</code> greater than or equal to
     *          <code>value</code> which divides <code>multiple</code> exactly.
     */
    public static int round_up(int value, int multiple) {
        return (((value - 1) / multiple) + 1) * multiple;
    }
}

Related

  1. round(Number number, Number unit)
  2. Round(Object in)
  3. round(String num, int length)
  4. round4(int n)
  5. round_pow2(int x)
  6. roundAdd(double a, double b)
  7. roundAndCrop(final float x, final int min, final int max)
  8. roundByGridSize(int value)
  9. roundByte(final double value)