Returns ceil (nNumerator / nDenominator). - Java java.lang

Java examples for java.lang:Math Function

Description

Returns ceil (nNumerator / nDenominator).

Demo Code

/*******************************************************************************
 * Copyright (c) 2011 Matthias-M. Christen, University of Basel, Switzerland.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser Public License v2.1
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * /* ww  w . j  a  v a2 s . co m*/
 * Contributors:
 *     Matthias-M. Christen, University of Basel, Switzerland - initial API and implementation
 ******************************************************************************/
//package com.java2s;

public class Main {
    /**
     * Returns
     * <code>ceil (<var>nNumerator</var> / <var>nDenominator</var>)</code>.
     * 
     * @param nNumerator
     *            The numerator
     * @param nDenominator
     *            The denomiator
     * @return <code>ceil (<var>nNumerator</var> / <var>nDenominator</var>)</code>
     */
    public static int divCeil(int nNumerator, int nDenominator) {
        return (nNumerator + nDenominator - 1) / nDenominator;
    }
}

Related Tutorials