Package com.android.utils
Class DecimalUtils
java.lang.Object
com.android.utils.DecimalUtils
public class DecimalUtils
extends java.lang.Object
Static methods for dealing with floating point numbers in string decimal form.
-
Method Summary
Modifier and Type Method Description static java.lang.StringtrimInsignificantZeros(java.lang.String floatingPointNumber)Removes trailing zeros after the decimal dot and also the dot itself if there are no non-zero digits after it.static java.lang.StringtrimInsignificantZeros(java.lang.String floatingPointNumber, char decimalSeparator, java.lang.String exponentialSeparator)Removes trailing zeros after the decimal separator and also the decimal separator itself if there are no non-zero digits after it.static java.lang.StringtrimInsignificantZeros(java.lang.String floatingPointNumber, java.text.DecimalFormatSymbols symbols)Removes trailing zeros after the decimal separator and also the decimal separator itself if there are no non-zero digits after it.
-
Method Details
-
trimInsignificantZeros
public static java.lang.String trimInsignificantZeros(java.lang.String floatingPointNumber)Removes trailing zeros after the decimal dot and also the dot itself if there are no non-zero digits after it. UsetrimInsignificantZeros(String, DecimalFormatSymbols)instead of this method if locale specific behavior is desired.- Parameters:
floatingPointNumber- the string representing a floating point number- Returns:
- the original number with trailing zeros removed
-
trimInsignificantZeros
public static java.lang.String trimInsignificantZeros(java.lang.String floatingPointNumber, java.text.DecimalFormatSymbols symbols)Removes trailing zeros after the decimal separator and also the decimal separator itself if there are no non-zero digits after it.- Parameters:
floatingPointNumber- the string representing a floating point numbersymbols- the decimal format symbols- Returns:
- the original number with trailing zeros removed
-
trimInsignificantZeros
public static java.lang.String trimInsignificantZeros(java.lang.String floatingPointNumber, char decimalSeparator, java.lang.String exponentialSeparator)Removes trailing zeros after the decimal separator and also the decimal separator itself if there are no non-zero digits after it.- Parameters:
floatingPointNumber- the string representing a floating point numberdecimalSeparator- the decimal separatorexponentialSeparator- the string used to separate the mantissa from the exponent- Returns:
- the original number with trailing zeros removed
-