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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:02:10+00:00 2026-05-23T05:02:10+00:00

Does anybody can explain to me why the execution of this program enters the

  • 0

Does anybody can explain to me why the execution of this program enters the infeasible if?
I know the existence of precisions problems with double and float, but I can’t figure out the problem in this example..

Thank you in advance!

NB: I compiled it under Ubuntu 10.10 with GCC 4.4.5

#include <stdio.h>

#define NUM_JOINTS 1

typedef struct {
    double t1;
    double t2;
    double t3;
} jointProfile;

jointProfile jp[NUM_JOINTS];

int main() {
    jp[0].t1 = 0.51639777949432230652604403076111339032649993896484375;
    jp[0].t2 = 0.00000000000000000000000000000000000000000000000000000;
    jp[0].t3 = 0.77459666924148340427791481488384306430816650390625000;

    double maxTime = (jp[0].t1 + jp[0].t2 + jp[0].t3);

    if ((jp[0].t1 + jp[0].t2 + jp[0].t3) < maxTime) {
        printf("Infeasible\n");
    }

    return 0;
}
  • 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-23T05:02:11+00:00Added an answer on May 23, 2026 at 5:02 am

    Well, apparently you don’t know enough about the subtleties of floating point computations.

    See e.g. http://download.oracle.com/docs/cd/E19957-01/806-3568/ncg_goldberg.html

    If you’re doing this on a 32-bit Ubuntu, the problem is likely that maxtime is spilled to memory and thus loses bits.

    One fix is to change the conditional to

    
    if (fabs(jp[0].t1 + jp[0].t2 + jp[0].t3 - maxtime) &lt DBL_EPSILON) {
     ...
    }
    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What does this following do? Can anybody explain me? $data = What is the
Can anybody explain the difference between cerr cout and clog and why does different
Does anybody know how can I determine where the user clicked in a DataGrid
Does anybody know how I can get the number of the elements (rows*cols) returned
Does anybody know how I can close all modal dialogs created by Dojo ?
Does anybody know if you can access the SaevFileDialog control that's used by the
Does anybody know where I can find a utility/application running on Windows that analyses
does anybody know how i can access a custom cell within the - (void)tableView:commitEditingStyle:forRowAtIndexPath:.
Does anybody know how I can theme the ctools modal window? I've tried putting
Does anybody know where I can get a free web crawler that actually works

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.