ProgramixGenericLib v4.0.0

com.programix.math
Class DecimalTools

java.lang.Object
  extended by com.programix.math.DecimalTools

public class DecimalTools
extends Object


Field Summary
static BigDecimal EIGHT
           
static BigDecimal EIGHTEEN
           
static BigDecimal EIGHTY
           
static BigDecimal EIGHTY_EIGHT
           
static BigDecimal EIGHTY_FIVE
           
static BigDecimal EIGHTY_FOUR
           
static BigDecimal EIGHTY_NINE
           
static BigDecimal EIGHTY_ONE
           
static BigDecimal EIGHTY_SEVEN
           
static BigDecimal EIGHTY_SIX
           
static BigDecimal EIGHTY_THREE
           
static BigDecimal EIGHTY_TWO
           
static BigDecimal ELEVEN
           
static BigDecimal FIFTEEN
           
static BigDecimal FIFTY
           
static BigDecimal FIFTY_EIGHT
           
static BigDecimal FIFTY_FIVE
           
static BigDecimal FIFTY_FOUR
           
static BigDecimal FIFTY_NINE
           
static BigDecimal FIFTY_ONE
           
static BigDecimal FIFTY_SEVEN
           
static BigDecimal FIFTY_SIX
           
static BigDecimal FIFTY_THREE
           
static BigDecimal FIFTY_TWO
           
static BigDecimal FIVE
           
static BigDecimal FORTY
           
static BigDecimal FORTY_EIGHT
           
static BigDecimal FORTY_FIVE
           
static BigDecimal FORTY_FOUR
           
static BigDecimal FORTY_NINE
           
static BigDecimal FORTY_ONE
           
static BigDecimal FORTY_SEVEN
           
static BigDecimal FORTY_SIX
           
static BigDecimal FORTY_THREE
           
static BigDecimal FORTY_TWO
           
static BigDecimal FOUR
           
static BigDecimal FOURTEEN
           
static char GROUPING_CHAR_COMMA
          The character ',' (comma).
static char GROUPING_CHAR_NONE
          Used to indicate that "thousands" should not be separated by any character at all (no grouping).
static BigDecimal NEGATIVE_ONE
          Equal to: -1
static BigDecimal NINE
           
static BigDecimal NINETEEN
           
static BigDecimal NINETY
           
static BigDecimal NINETY_EIGHT
           
static BigDecimal NINETY_FIVE
           
static BigDecimal NINETY_FOUR
           
static BigDecimal NINETY_NINE
           
static BigDecimal NINETY_ONE
           
static BigDecimal NINETY_SEVEN
           
static BigDecimal NINETY_SIX
           
static BigDecimal NINETY_THREE
           
static BigDecimal NINETY_TWO
           
static BigDecimal ONE
           
static BigDecimal ONE_BILLION
           
static BigDecimal ONE_EIGHTH
          Equal to: 0.125 (3 decimal places)
static BigDecimal ONE_ELEVENTH
          Equal to: 0.0909090909090909090909091 (25 decimal places)
static BigDecimal ONE_FIFTH
          Equal to: 0.2 (1 decimal place)
static BigDecimal ONE_FOURTH
          Alternate name for ONE_QUARTER
static BigDecimal ONE_HALF
          Equal to: 0.5 (1 decimal place)
static BigDecimal ONE_HUNDRED
           
static BigDecimal ONE_HUNDRED_BILLION
           
static BigDecimal ONE_HUNDRED_MILLION
           
static BigDecimal ONE_HUNDRED_THOUSAND
           
static BigDecimal ONE_HUNDREDTH
          Equal to: 0.01 (2 decimal places)
static BigDecimal ONE_MILLION
           
static BigDecimal ONE_MILLIONTH
          Equal to: 0.00001 (5 decimal places)
static BigDecimal ONE_NINTH
          Equal to: 0.1111111111111111111111111 (25 decimal places)
static BigDecimal ONE_QUARTER
          Equal to: 0.25 (2 decimal places)
static BigDecimal ONE_SEVENTH
          Equal to: 0.1428571428571428571428571 (25 decimal places)
static BigDecimal ONE_SIXTEENTH
          Equal to: 0.0625 (4 decimal places)
static BigDecimal ONE_SIXTH
          Equal to: 0.1666666666666666666666667 (25 decimal places)
static BigDecimal ONE_TEN_THOUSANDTH
          Equal to: 0.0001 (4 decimal places)
static BigDecimal ONE_TENTH
          Equal to: 0.1 (1 decimal place)
static BigDecimal ONE_THIRD
          Equal to: 0.3333333333333333333333333 (25 decimal places)
static BigDecimal ONE_THOUSAND
           
static BigDecimal ONE_THOUSANDTH
          Equal to: 0.001 (3 decimal places)
static BigDecimal ONE_TRILLION
           
static BigDecimal ONE_TWELFTH
          Equal to: 0.0833333333333333333333333 (25 decimal places)
static char PAD_CHAR_NONE
          Used to indicate that there should not be any any padding done at all.
static char PAD_CHAR_SPACE
          The character ' ' (space).
static char PAD_CHAR_ZERO
          The character '0' (zero).
static BigDecimal SEVEN
           
static BigDecimal SEVENTEEN
           
static BigDecimal SEVENTY
           
static BigDecimal SEVENTY_EIGHT
           
static BigDecimal SEVENTY_FIVE
           
static BigDecimal SEVENTY_FOUR
           
static BigDecimal SEVENTY_NINE
           
static BigDecimal SEVENTY_ONE
           
static BigDecimal SEVENTY_SEVEN
           
static BigDecimal SEVENTY_SIX
           
static BigDecimal SEVENTY_THREE
           
static BigDecimal SEVENTY_TWO
           
static BigDecimal SIX
           
static BigDecimal SIXTEEN
           
static BigDecimal SIXTY
           
static BigDecimal SIXTY_EIGHT
           
static BigDecimal SIXTY_FIVE
           
static BigDecimal SIXTY_FOUR
           
static BigDecimal SIXTY_NINE
           
static BigDecimal SIXTY_ONE
           
static BigDecimal SIXTY_SEVEN
           
static BigDecimal SIXTY_SIX
           
static BigDecimal SIXTY_THREE
           
static BigDecimal SIXTY_TWO
           
static BigDecimal TEN
           
static BigDecimal TEN_BILLION
           
static BigDecimal TEN_MILLION
           
static BigDecimal TEN_THOUSAND
           
static BigDecimal THIRTEEN
           
static BigDecimal THIRTY
           
static BigDecimal THIRTY_EIGHT
           
static BigDecimal THIRTY_FIVE
           
static BigDecimal THIRTY_FOUR
           
static BigDecimal THIRTY_NINE
           
static BigDecimal THIRTY_ONE
           
static BigDecimal THIRTY_SEVEN
           
static BigDecimal THIRTY_SIX
           
static BigDecimal THIRTY_THREE
           
static BigDecimal THIRTY_TWO
           
static BigDecimal THREE
           
static BigDecimal TWELVE
           
static BigDecimal TWENTY
           
static BigDecimal TWENTY_EIGHT
           
static BigDecimal TWENTY_FIVE
           
static BigDecimal TWENTY_FOUR
           
static BigDecimal TWENTY_NINE
           
static BigDecimal TWENTY_ONE
           
static BigDecimal TWENTY_SEVEN
           
static BigDecimal TWENTY_SIX
           
static BigDecimal TWENTY_THREE
           
static BigDecimal TWENTY_TWO
           
static BigDecimal TWO
           
static BigDecimal ZERO
           
static BigDecimal[] ZERO_LEN_ARRAY
          An array of BigDecimal with a length of zero.
 
Method Summary
static BigDecimal convert(int value)
          Converts the specified value to a BigDecimal returning one of the shared, common, immutable instances if possible.
static BigDecimal convert(long value)
          Converts the specified value to a BigDecimal returning one of the shared, common, immutable instances if possible.
static BigDecimal convert(Number value)
          Converts the specified value to a BigDecimal returning one of the shared, common, immutable instances if possible.
static boolean equalTo(BigDecimal a, BigDecimal b)
          Returns true if a is numerically equal to b (with no regard to scale).
static String format(BigDecimal value, int integerDigitCount, char integerPaddingChar, int fractionalDigitCount, char fractionalPaddingChar, char thousandGroupingChar)
           
static String format(BigDecimal value, int integerDigitCount, int fractionalDigitCount)
           
static BigDecimal getMaxValueFor(int integerDigitCount, int fractionalDigitCount)
          Returns the largest positive value than can fit into the specified number of integer and fractional digits (all nines).
static BigDecimal getMinValueFor(int integerDigitCount, int fractionalDigitCount)
          Returns the most negative value than can fit into the specified number of integer and fractional digits (all nines preceded by a minus sign).
static boolean greaterThan(BigDecimal a, BigDecimal b)
          Returns true if a is numerically greater than b (with no regard to scale).
static boolean greaterThanOrEqualTo(BigDecimal a, BigDecimal b)
          Returns true if a is numerically greater than or equal to b (with no regard to scale).
static boolean isDifferent(BigDecimal a, BigDecimal b)
          Compares two BigDecimals to see if they are "different" (without regard to the scales of each one).
static boolean isEmpty(BigDecimal val)
          Returns true if the specified BigDecimal is either null or zero.
static boolean isNegative(BigDecimal val)
          Returns true if val is negative (numerically less than ZERO).
static boolean isNotEmpty(BigDecimal val)
          Returns true if the specified BigDecimal is not null and is not equal to zero.
static boolean isNotNegative(BigDecimal val)
          Returns true if val is non-negative (numerically greater than or equal to ZERO).
static boolean isNotPositive(BigDecimal val)
          Returns true if val is non-positive (numerically less than or equal to ZERO).
static boolean isNotZero(BigDecimal val)
          Returns true if val is numerically not equal to ZERO (with no regard to scale).
static boolean isPositive(BigDecimal val)
          Returns true if val is positive (numerically greater than ZERO).
static boolean isSame(BigDecimal a, BigDecimal b)
          Compares two BigDecimals to see if they are the "same" (without regard to the scales of each one).
static boolean isZero(BigDecimal val)
          Returns true if val is numerically equal to ZERO (with no regard to scale).
static boolean lessThan(BigDecimal a, BigDecimal b)
          Returns true if a is numerically less than b (with no regard to scale).
static boolean lessThanOrEqualTo(BigDecimal a, BigDecimal b)
          Returns true if a is numerically less than or equal to b (with no regard to scale).
static BigDecimal max(BigDecimal a, BigDecimal b)
          Returns the numerically larger of a and b (with no regard to scale).
static BigDecimal max(BigDecimal a, BigDecimal b, BigDecimal c)
          Returns the numerically largest of a, b and c (with no regard to scale).
static BigDecimal min(BigDecimal a, BigDecimal b)
          Returns the numerically smaller of a and b (with no regard to scale).
static BigDecimal min(BigDecimal a, BigDecimal b, BigDecimal c)
          Returns the numerically smallest of a, b and c (with no regard to scale).
static boolean notEqualTo(BigDecimal a, BigDecimal b)
          Returns true if a is numerically not equal to b (with no regard to scale).
static boolean notGreaterThan(BigDecimal a, BigDecimal b)
          Returns true if a is numerically not greater than b (with no regard to scale).
static boolean notLessThan(BigDecimal a, BigDecimal b)
          Returns true if a is numerically not less than b (with no regard to scale).
static BigDecimal parseBigDecimal(String source)
          Permissively parses the passed String into a BigDecimal.
static BigDecimal parseBigDecimal(String source, BigDecimal defaultValue)
          Permissively parses the passed String into a BigDecimal.
static double parseDouble(String source)
          Permissively parses the passed String into a double.
static double parseDouble(String source, double defaultValue)
          Permissively parses the passed String into a double.
static Value parseValue(String source)
          Permissively parses the passed String into a Value that if not empty, wraps an instance of BigDecimal.
static BigDecimal rangeBound(BigDecimal minValue, BigDecimal value, BigDecimal maxValue)
          Bounds value to the specified range.
static BigDecimal round(BigDecimal value)
          Rounds to the nearest 1 (nearest integer).
static BigDecimal round(BigDecimal value, BigDecimal nearest)
          Equivalent to: round(value, nearest, BigDecimal.ROUND_HALF_UP)
static BigDecimal round(BigDecimal value, BigDecimal nearest, int roundingMode)
          Returns value rounded to the nearest multiple of the specified value nearest.
static BigDecimal roundDollar(BigDecimal value)
          Same as round(BigDecimal) (nearest integer).
static BigDecimal roundEighth(BigDecimal value)
          Rounds to the nearest 1/8 (multiple of 0.125).
static BigDecimal roundHalf(BigDecimal value)
          Rounds to the nearest 1/2 (multiple of 0.5).
static BigDecimal roundHundredth(BigDecimal value)
          Rounds to the nearest 0.01.
static BigDecimal roundPenny(BigDecimal value)
          Same as roundHundredth(BigDecimal).
static BigDecimal roundQuarter(BigDecimal value)
          Rounds to the nearest 1/4 (multiple of 0.25).
static BigDecimal roundSixteenth(BigDecimal value)
          Rounds to the nearest 1/16 (multiple of 0.0625).
static BigDecimal roundTenth(BigDecimal value)
          Rounds to the nearest 0.1.
static BigDecimal roundThousandth(BigDecimal value)
          Rounds to the nearest 0.001.
static BigDecimal sum(BigDecimal[] val)
          Returns the sum of all of the values in the array passed in.
static BigDecimal[] toArray(Collection bigDecimals)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ZERO

public static final BigDecimal ZERO

ONE

public static final BigDecimal ONE

TWO

public static final BigDecimal TWO

THREE

public static final BigDecimal THREE

FOUR

public static final BigDecimal FOUR

FIVE

public static final BigDecimal FIVE

SIX

public static final BigDecimal SIX

SEVEN

public static final BigDecimal SEVEN

EIGHT

public static final BigDecimal EIGHT

NINE

public static final BigDecimal NINE

TEN

public static final BigDecimal TEN

ELEVEN

public static final BigDecimal ELEVEN

TWELVE

public static final BigDecimal TWELVE

THIRTEEN

public static final BigDecimal THIRTEEN

FOURTEEN

public static final BigDecimal FOURTEEN

FIFTEEN

public static final BigDecimal FIFTEEN

SIXTEEN

public static final BigDecimal SIXTEEN

SEVENTEEN

public static final BigDecimal SEVENTEEN

EIGHTEEN

public static final BigDecimal EIGHTEEN

NINETEEN

public static final BigDecimal NINETEEN

TWENTY

public static final BigDecimal TWENTY

TWENTY_ONE

public static final BigDecimal TWENTY_ONE

TWENTY_TWO

public static final BigDecimal TWENTY_TWO

TWENTY_THREE

public static final BigDecimal TWENTY_THREE

TWENTY_FOUR

public static final BigDecimal TWENTY_FOUR

TWENTY_FIVE

public static final BigDecimal TWENTY_FIVE

TWENTY_SIX

public static final BigDecimal TWENTY_SIX

TWENTY_SEVEN

public static final BigDecimal TWENTY_SEVEN

TWENTY_EIGHT

public static final BigDecimal TWENTY_EIGHT

TWENTY_NINE

public static final BigDecimal TWENTY_NINE

THIRTY

public static final BigDecimal THIRTY

THIRTY_ONE

public static final BigDecimal THIRTY_ONE

THIRTY_TWO

public static final BigDecimal THIRTY_TWO

THIRTY_THREE

public static final BigDecimal THIRTY_THREE

THIRTY_FOUR

public static final BigDecimal THIRTY_FOUR

THIRTY_FIVE

public static final BigDecimal THIRTY_FIVE

THIRTY_SIX

public static final BigDecimal THIRTY_SIX

THIRTY_SEVEN

public static final BigDecimal THIRTY_SEVEN

THIRTY_EIGHT

public static final BigDecimal THIRTY_EIGHT

THIRTY_NINE

public static final BigDecimal THIRTY_NINE

FORTY

public static final BigDecimal FORTY

FORTY_ONE

public static final BigDecimal FORTY_ONE

FORTY_TWO

public static final BigDecimal FORTY_TWO

FORTY_THREE

public static final BigDecimal FORTY_THREE

FORTY_FOUR

public static final BigDecimal FORTY_FOUR

FORTY_FIVE

public static final BigDecimal FORTY_FIVE

FORTY_SIX

public static final BigDecimal FORTY_SIX

FORTY_SEVEN

public static final BigDecimal FORTY_SEVEN

FORTY_EIGHT

public static final BigDecimal FORTY_EIGHT

FORTY_NINE

public static final BigDecimal FORTY_NINE

FIFTY

public static final BigDecimal FIFTY

FIFTY_ONE

public static final BigDecimal FIFTY_ONE

FIFTY_TWO

public static final BigDecimal FIFTY_TWO

FIFTY_THREE

public static final BigDecimal FIFTY_THREE

FIFTY_FOUR

public static final BigDecimal FIFTY_FOUR

FIFTY_FIVE

public static final BigDecimal FIFTY_FIVE

FIFTY_SIX

public static final BigDecimal FIFTY_SIX

FIFTY_SEVEN

public static final BigDecimal FIFTY_SEVEN

FIFTY_EIGHT

public static final BigDecimal FIFTY_EIGHT

FIFTY_NINE

public static final BigDecimal FIFTY_NINE

SIXTY

public static final BigDecimal SIXTY

SIXTY_ONE

public static final BigDecimal SIXTY_ONE

SIXTY_TWO

public static final BigDecimal SIXTY_TWO

SIXTY_THREE

public static final BigDecimal SIXTY_THREE

SIXTY_FOUR

public static final BigDecimal SIXTY_FOUR

SIXTY_FIVE

public static final BigDecimal SIXTY_FIVE

SIXTY_SIX

public static final BigDecimal SIXTY_SIX

SIXTY_SEVEN

public static final BigDecimal SIXTY_SEVEN

SIXTY_EIGHT

public static final BigDecimal SIXTY_EIGHT

SIXTY_NINE

public static final BigDecimal SIXTY_NINE

SEVENTY

public static final BigDecimal SEVENTY

SEVENTY_ONE

public static final BigDecimal SEVENTY_ONE

SEVENTY_TWO

public static final BigDecimal SEVENTY_TWO

SEVENTY_THREE

<