When calculating and manipulating probabilities in Java and then expressing them as a percentage, what is the best data structure to represent them?
Native double and float do not seem to be particularly ideal candidates, since they have problems with odd rounding, which can lead to errors when rounding occurs several times and is aggravated.
BigInteger works well for calculating permutations and combinations, and BigDecimal seems like it might be a good candidate for non-integer values, but is there something more suitable for handling percentages?
Note. In this case, the calculated probabilities are similar in nature to those associated with decks of cards, but with hundreds of cards. For more mathematics, I specifically work with Multidimensional hypergeometric_distributions .
source share