Here you can find the source of FormatDouble(final double dblValue, final int iNumLeft, final int iNumRight, final double dblMultiplier)
Parameter | Description |
---|---|
dblValue | Double representing the input |
iNumLeft | Integer representing the number of left justifying zeros |
iNumRight | Integer representing the number of right justifying zeros |
dblMultiplier | Double representing the multiplier |
public static final java.lang.String FormatDouble(final double dblValue, final int iNumLeft, final int iNumRight, final double dblMultiplier)
//package com.java2s; /*!//from w w w . j a va 2 s.co m * Copyright (C) 2013 Lakshmi Krishnamurthy * Copyright (C) 2012 Lakshmi Krishnamurthy * * This file is part of CreditAnalytics, a free-software/open-source library for fixed income analysts and * developers - http://www.credit-trader.org * * CreditAnalytics is a free, full featured, fixed income credit analytics library, developed with a special * focus towards the needs of the bonds and credit products community. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * limitations under the License. */ public class Main { /** * Format the double input by multiplying, and then adding left and right adjustments * * @param dblValue Double representing the input * @param iNumLeft Integer representing the number of left justifying zeros * @param iNumRight Integer representing the number of right justifying zeros * @param dblMultiplier Double representing the multiplier * * @return String representing the formatted input */ public static final java.lang.String FormatDouble(final double dblValue, final int iNumLeft, final int iNumRight, final double dblMultiplier) { java.lang.String strFormat = "#"; for (int i = 0; i < iNumLeft; ++i) strFormat += "0"; if (0 != iNumRight) { strFormat += "."; for (int i = 0; i < iNumRight; ++i) strFormat += "0"; } return new java.text.DecimalFormat(strFormat).format(dblMultiplier * dblValue); } }