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 7688475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:55:45+00:00 2026-05-31T19:55:45+00:00

Another developer has given me an algorithm that returns a series of strings that

  • 0

Another developer has given me an algorithm that returns a series of strings that contain stringified doubles. I am building unit tests against these string outputs. About 80% of the time I run my unit tests they all pass. The other 20% of the time slight variations occur in the double portion of the returned strings. For example:

Expected: ((B,D),(C,A)); : 0.05766153477579324
Found:    ((B,D),(C,A)); : 0.05766153477579325

Expected: (B,(C,(A,D))); : 0.0017518688483315935
Found     (B,(C,(A,D))); : 0.001751868848331593

I know that double computations can be imprecise, but I have never heard of them being variant. I am assured by the algorithm author that the algo is deterministic. The way that the double is being toStringed is:

    for(Tree gt: geneTrees){
        double prob = probList.next();
        total += prob;
        result.append("\n" + gt.toString() + " : " + prob);
    }

I am at a bit of a loss explain how this variation is possible. Any ideas?

  • 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-31T19:55:46+00:00Added an answer on May 31, 2026 at 7:55 pm

    Just based on the summing that you’re doing, I suspect that this might be caused by the issue that double addition is not quite commutative or associative — you’ll get different rounding errors if you add doubles in a slightly different order.

    Just add a small epsilon for your unit tests, basically.

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

Sidebar

Related Questions

I am reviewing another developer's code and he has written a lot of code
I've got the following bit of code (that another developer wrote) that I need
I'm working on some code that dropped on me when another developer (and the
I want another developer to run a Perl script I have written. The script
I had another developer ask why I use List all over the place ...
I have a situation where another developer is including source files from a project
I acquired a database from another developer. He didn't use auto_incrementers on any tables.
I've got a function written by another developer which I am trying to modify
I recently had a discussion on another forum with another developer and the topic
I'm supporting an existing application written by another developer and I have a question

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.