Java Number Divide div(long v1, long v2)

Here you can find the source of div(long v1, long v2)

Description

div

License

Open Source License

Parameter

Parameter Description
v1 a parameter
v2 a parameter

Declaration

public static long div(long v1, long v2) 

Method Source Code

//package com.java2s;
/**/*from w  w w  .j  a  v a2 s  .com*/
 * (C) 2011-2012 Alibaba Group Holding Limited.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * version 2 as published by the Free Software Foundation.
 * 
 */

import java.math.BigDecimal;

public class Main {
    /**
     * @param v1
     * @param v2
     * @return
     */
    public static long div(long v1, long v2) {
        BigDecimal b1 = new BigDecimal(v1);
        BigDecimal b2 = new BigDecimal(v2);
        return b1.divide(b2, 0, BigDecimal.ROUND_HALF_UP).longValue();
    }
}

Related

  1. div(double v1, double v2)
  2. div(Double v1, Double v2)
  3. div(Double v1, Double v2)
  4. div(double v1, double v2)
  5. div(double v1, double v2, int scale)
  6. div(Object a, Object b)
  7. divide(Number a, Number b, Class cl)
  8. divide(Number n1, Number n2)
  9. divide(Number n1, Number n2)