Here you can find the source of div(long dividend, long divisor)
private static long div(long dividend, long divisor)
//package com.java2s; /******************************************************************************* * Copyright (c) 2004-2010 Sunil Kamath (IcemanK). * All rights reserved.// w w w . j a v a 2 s . c o m * This program is made available under the terms of the Common Public License * v1.0 which is available at http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * Sunil Kamath (IcemanK) - initial API and implementation *******************************************************************************/ public class Main { private static long div(long dividend, long divisor) { if (dividend < 0) { return Math.round((double) (dividend - divisor + 1) / (double) divisor); } return Math.round((double) dividend / (double) divisor); } }