Java Long Number Divide divide(Long d1, Long d2)

Here you can find the source of divide(Long d1, Long d2)

Description

divide

License

Open Source License

Declaration

public static String divide(Long d1, Long d2) 

Method Source Code


//package com.java2s;
/*//from w w w.j  a  v a  2  s . co m
 * Copyright 2014 Alibaba.com All right reserved. This software is the
 * confidential and proprietary information of Alibaba.com ("Confidential
 * Information"). You shall not disclose such Confidential Information and shall
 * use it only in accordance with the terms of the license agreement you entered
 * into with Alibaba.com.
 */

import java.text.DecimalFormat;

public class Main {
    public static String divide(Long d1, Long d2) {

        if (d1 == null || d2 == null || d2.equals(0l)) {
            return "0";
        }

        double percent = (double) d1 / d2;
        DecimalFormat format = new DecimalFormat("0.00");
        return format.format(percent);
    }
}

Related

  1. div(long dividend, long divisor)
  2. div100(Long input)
  3. div_ceil(long n, long d)
  4. divCeil(long a, long b)
  5. divide(final long dividend, final long divisor)
  6. divide(long dividend, long divisor)
  7. divide(long l1, long l2)
  8. divideAndRoundUp(long x, long y)
  9. divideForMean(long sum, long count)