@Immutable public final class RoundHelper extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
RoundHelper.EDecimalType |
| Modifier and Type | Method and Description |
|---|---|
static String |
getFormatted(double dValue,
int nScale,
RoundHelper.EDecimalType eType,
Locale aLocale)
Source: http://www.luschny.de/java/doubleformat.html
|
static String |
getFormattedExp(double dValue,
int nScale,
Locale aLocale) |
static String |
getFormattedExp2(double dValue,
Locale aLocale) |
static String |
getFormattedFix(double dValue,
int nScale,
Locale aLocale) |
static String |
getFormattedFix2(double dValue,
Locale aLocale) |
static double |
getRounded(double dValue,
int nScale,
RoundingMode eMode,
RoundHelper.EDecimalType eType)
Source: http://www.luschny.de/java/doubleformat.html
|
static double |
getRoundedEvenExp(double dValue,
int nScale)
Round using the
RoundingMode.HALF_EVEN mode and exponential
representation |
static double |
getRoundedEvenExp2(double dValue)
Round using the
RoundingMode.HALF_EVEN mode, exponential
representation and a precision scale of 2. |
static double |
getRoundedUpFix(double dValue,
int nScale)
Round using the
RoundingMode.HALF_UP mode and fix representation |
static double |
getRoundedUpFix2(double dValue)
Round using the
RoundingMode.HALF_UP mode, fix representation and a
precision scale of 2. |
public static double getRounded(double dValue,
@Nonnegative
int nScale,
@Nonnull
RoundingMode eMode,
@Nonnull
RoundHelper.EDecimalType eType)
dValue - The value to be roundednScale - The precision of the decimal scale. If type is
RoundHelper.EDecimalType.FIX the decimal scale, else the (carrying scale
- 1). Should be ≥ 0.eType - The formatting type. May not be null.eMode - The rounding mode to be used. May not be null.public static double getRoundedUpFix(double dValue,
@Nonnegative
int nScale)
RoundingMode.HALF_UP mode and fix representationdValue - The value to be roundednScale - The precision scalepublic static double getRoundedUpFix2(double dValue)
RoundingMode.HALF_UP mode, fix representation and a
precision scale of 2.dValue - The value to be roundedpublic static double getRoundedEvenExp(double dValue,
@Nonnegative
int nScale)
RoundingMode.HALF_EVEN mode and exponential
representationdValue - The value to be roundednScale - The precision scalepublic static double getRoundedEvenExp2(double dValue)
RoundingMode.HALF_EVEN mode, exponential
representation and a precision scale of 2.dValue - The value to be rounded@Nonnull public static String getFormatted(double dValue, @Nonnegative int nScale, @Nonnull RoundHelper.EDecimalType eType, @Nonnull Locale aLocale)
dValue - the value to be formattednScale - The precision of the decimal scale. If type is
RoundHelper.EDecimalType.FIX the decimal scale, else the (carrying scale
- 1). Should be ≥ 0.eType - The formatting type. May not be null.aLocale - The locale to be used for the decimal symbols. May not be
null.Double.toString() is returned.@Nonnull public static String getFormattedFix(double dValue, @Nonnegative int nScale, Locale aLocale)
@Nonnull public static String getFormattedExp(double dValue, @Nonnegative int nScale, Locale aLocale)
Copyright © 2006–2015 phloc systems. All rights reserved.