Java Double Number Round getRatioString(double n, double d)

Here you can find the source of getRatioString(double n, double d)

Description

get Ratio String

License

Open Source License

Declaration

public static String getRatioString(double n, double d) 

Method Source Code

//package com.java2s;
/**//  w ww .  ja  va 2 s  .c  o  m
 * PureInfo QuakeCenter
 * @(#)MyTabeleDataHelper.java   1.0 2005-12-1
 * 
 * Copyright(c) 2004-2005, PureInfo Information Technology Corp. Ltd. 
 * All rights reserved, see the license file.
 * 
 * www.pureinfo.com.cn
 */

import java.text.DecimalFormat;

public class Main {
    public static String getRatioString(double n, double d) {
        if (d < 0.0001) {
            return "----";
        }
        DecimalFormat format = new DecimalFormat("#0.0%");
        return format.format(n / d);
    }
}

Related

  1. round(double a)
  2. Round(double a)
  3. round(double a)
  4. round(double a, double precision)