Java Integer Divide divUp(int dividend, int divisor)

Here you can find the source of divUp(int dividend, int divisor)

Description

divides integers with rounding up

License

Open Source License

Parameter

Parameter Description
dividend a parameter
divisor a parameter

Return

quotient rounded to upper integer

Declaration

public static int divUp(int dividend, int divisor) 

Method Source Code

//package com.java2s;
/*//from www. java  2  s . c  o m
 *  Big Database Semantic Metric Tools
 *
 * Copyright (C) 2011 OpenLink Software <bdsmt@openlinksw.com>
 * All Rights Reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation;  only Version 2 of the License dated
 * June 1991.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

public class Main {
    /** divides integers with rounding up
     * @param dividend
     * @param divisor
     * @return quotient rounded to upper integer
     */
    public static int divUp(int dividend, int divisor) {
        return (dividend + divisor - 1) / divisor;
    }
}

Related

  1. division(int i_Divisor, int i_Dividend)
  2. divisor(int a, int b)
  3. divisor(int m, int n)
  4. divisorMod(int a, int n)
  5. divRoundUp(int a, int b)