Here you can find the source of floorDiv(int dividend, int divisor)
dividend/divisor
which is useful when dividing potentially negative numbers into bins.
public static int floorDiv(int dividend, int divisor)
//package com.java2s; // under the terms of the GNU Lesser General Public License as published public class Main { /**//from w ww . java 2 s . co m * Computes the floored division <code>dividend/divisor</code> which * is useful when dividing potentially negative numbers into bins. For * positive numbers, it is the same as normal division, for negative * numbers it returns <code>(dividend - divisor + 1) / divisor</code>. * * <p> For example, the following numbers floorDiv 10 are: * <pre> * -15 -10 -8 -2 0 2 8 10 15 * -2 -1 -1 -1 0 0 0 1 1 * </pre> */ public static int floorDiv(int dividend, int divisor) { return ((dividend >= 0) ? dividend : (dividend - divisor + 1)) / divisor; } }