Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6709647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:54:24+00:00 2026-05-26T07:54:24+00:00

When calculating and manipulating probabilities in Java, and then expressing them as percentages, what

  • 0

When calculating and manipulating probabilities in Java, and then expressing them as percentages, what is the best data structure to use to represent them?

The native double and float don’t seem like particularly ideal candidates, since they have odd rounding issues which can introduce errors when the rounding happens multiple times and gets compounded.

BigInteger works well for calculating permutations and combinations, and BigDecimal seems like it might be a good candidate for the non-integer values, but is there something more suited to dealing with percentages already?

Note: In this case, the probabilities being calculated are similar in nature to those involving decks of cards, but with hundreds of cards. For the more math-inclined, I’m specifically working with Multivariate Hypergeometric_distributions.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T07:54:25+00:00Added an answer on May 26, 2026 at 7:54 am

    When it comes to probabilities, I would suspect you would benefit from working with fractions.

    Have a look at this question:

    • Best way to represent a fraction in Java?

    Otherwise I think BigDecimal is your best choice. Beware however of the java.lang.ArithmeticException: Non-terminating decimal expansion;

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Without calculating them , I mean?
I am calculating 16 bit checksum on my data which i need to send
I am calculating percentages in Analysis Services 2008 using MDX by dividing the sum
What is the best approach to calculating the largest prime factor of a number?
I'm calculating fixedpoint reciprocals in Q22.10 with Goldschmidt division for use in my software
I would appreciate some advice related to manipulating data in vectors. I have written
I am calculating percentages. One example is coming down to 38589/38400 So the percentage
I am calculating the MD5 in Android/Java as follows: byte raw[] = md.digest(); StringBuffer
My entities currently contain java Date properties. I'm starting to use Joda Time for
Possible Duplicate: Calculating the Difference Between Two Java Date Instances In Java, I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.