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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:58:57+00:00 2026-06-17T17:58:57+00:00

I have got a problem. I got this function in a class invKin to

  • 0

I have got a problem. I got this function in a class “invKin” to set some parameters before I ran a simulation:

void IK_mm4::set_timesetting(double *T_horiz_, double *delta_t_)
{
  T_horiz  = T_horiz_;
  delta_t  = delta_t_;

  k_end = (int)floor((*T_horiz)/(*delta_t));

  cout << "k_end = " << k_end <<endl;
}

It is invoked in my main-file with

...
double delta_t = 5e-3;
double *T_desired = new double(5.0);
...
invKin.set_timesetting(T_desired,&delta_t);
...

The problem is now. At the PC at my university everything is fine and k_end has the value ‘1000’ as it should have. At my home PC the system is somehow giving back the value ‘999’. If I change the value of *T_desired down to ‘0.05’ cout is giving the right value of ’10’ at both PCs.

I have already checked to use a variable

double k_end_test = (*T_horiz)/(*delta_t);

that is giving the correct solution of ‘1000’. The error must be in the floor function or the int-conversion. If I do

int k_end_test2 = (int)(k_end_test);

or

double k_end_test2 = floor(k_end_test);

the result is always ‘999’.

Does somebody have an idea where this can come from?

I am thankful for any kind of hints! Thank You!

  • 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-06-17T17:58:58+00:00Added an answer on June 17, 2026 at 5:58 pm

    This is the nature of limited-precision representations.

    For example, consider six decimal digits of precision. This is not what double uses, of course, but the concept is precisely the same. 1/3 is .333333 with six digits of decimal precision. So 30 * (1/3) is 9.99999. If you round down to an integer, you get 9, not 10. This is the problem you are seeing.

    If you don’t want this behavior, don’t use floating point.

    It may suffice to add a small “delta” to the value you pass to floor.

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

Sidebar

Related Questions

I'm getting crazy with this problem: I have got some Oracle SQL-Reports to redesign
I have got a problem with my actionscript class. This is my code: package
I have got this function that returns a constant..Here is my class and function:
ok i got this problem. i have this routes: (code bit change) File:/home/dotcloud/current/config/routes.js exports.routes
I' ve got a problem with Haskell. I have text file looking like this:
I have odd problem: After starting server I got this error: undefined local variable
I have a simple problem with XML got from database. Now, this XML can
i have a problem while loading a UITableView on UITabBarController, i got this error
I have got a problem with calling a global function, which takes a pointer
I have been working on the app engine for some time, and this problem

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.