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

  • SEARCH
  • Home
  • 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 4595570
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T22:59:21+00:00 2026-05-21T22:59:21+00:00

I have basically four numbers (say 100, 200, 300, 400), and I need to

  • 0

I have basically four numbers (say 100, 200, 300, 400), and I need to calculate the probability as 100/(100+200+300+400), 200/(100+200+300+400), and so on.

When I use the decimal data type to store these probabilities, they don’t up to one due to round issues. What’s the best way to past this without making the probabilities too inaccurate? Basically I do this calculation many many times, so I don’t want to have to change all the divisions into Math.Round stuff. 😐

  • 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-21T22:59:22+00:00Added an answer on May 21, 2026 at 10:59 pm

    The solution is straightforward: if it hurts when you do that then don’t do that.

    If you have rational probabilities, that is, probabilities that are ratios of whole numbers, and you want them to add to exactly one, then don’t convert them to decimal or double in the first place. Use an arbitrary-precision rational type to represent your arbitrary precision rationals.

    There’s an arbitrary-precision rational type included with Microsoft Solver Foundation; you could download and use that. Or, it is easy to write your own by simply making an immutable struct that has two BigIntegers for the numerator and denominator, and then write implementations of the operators you need.

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

Sidebar

Related Questions

I have have a simple HTML form with say four input widgets (see below)...two
I have four numbers that can possible be the same, but or most likely
I have a data gathering app (terrestrial magnetic field strength) that has four phases;
I have four levels of filter, basically: format, region, demographics and interests. <div class=form-div>
Basically if I have a div loaded onto a page with a data-test attribute
I have build a c# code which would basically take four arguments a1 a2
Basically I have developed an application in C++ and have four classes. The functionality
I have (basically) this code - <script type=text/javascript language=javascript> $(document).ready(function() { $(#loadDiv).load(mypage.html, function(){ alert($(#someText).text())
I have basically two questions. How do I locate the default Rprofile which is
I have basically the same problem outlined in this question, however I am using

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.