Java Integer Divide divisor(int a, int b)

Here you can find the source of divisor(int a, int b)

Description

divisor

License

Apache License

Parameter

Parameter Description
a either a positive or negative integer.
b a positive integer.

Declaration

static public int divisor(int a, int b) 

Method Source Code

//package com.java2s;
/**/*from   ww  w  .j a va  2  s  . c o  m*/
 * Copyright 2014, Emory University
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

public class Main {
    /**
     * @param a either a positive or negative integer.
     * @param b a positive integer.
     */
    static public int divisor(int a, int b) {
        return (a < 0) ? ((a % b) + b) % b : a % b;
    }
}

Related

  1. divideToInt(String address)
  2. divideUnsigned(int dividend, int divisor)
  3. divideWithCeilingRoundingMode(int p, int q)
  4. divideWithoutOverflow(int x, int y)
  5. division(int i_Divisor, int i_Dividend)
  6. divisor(int m, int n)
  7. divisorMod(int a, int n)
  8. divRoundUp(int a, int b)
  9. divUp(int dividend, int divisor)