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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:27:52+00:00 2026-06-15T07:27:52+00:00

Possible Duplicate: Dealing with accuracy problems in floating-point numbers I am writing an OpenGl

  • 0

Possible Duplicate:
Dealing with accuracy problems in floating-point numbers

I am writing an OpenGl animation and am using a float variable “time” to keep track of the time.
I am incrementing the “time” variable by 0.01 .I have certain conditions to fulfil whenever “time” reaches an integer value.The issue is that after a certain time the float increment shows weird behavior.
I start from time = 0 and I see that after “time” reaches 0.83 the next value is 0.839999.
I though this could be related to float precision so I tried using double/long double and I found that instead of reaching the value 1.00 the code is reaching the value 1.0000007.

I tried incrementing by “0.01f” instead of “0.01” but got no success.
Is this some bug in Visual Studio or am I doing it the wrong way?
I could post the code but I don’t think it’s of much use as I am assigning to “time” just at one place and it’s just being used at other places.

  • 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-15T07:27:53+00:00Added an answer on June 15, 2026 at 7:27 am

    Don’t ever compare floating point values for equality unless you know exactly what you are doing. I would strongly suggest you use integers (perhaps integer numbers of milliseconds) for this purpose.

    See What Every Computer Scientist Should Know About Floating-Point Arithmetic for more information.

    Floating point is a fixed-precision format. This is an inherent limitation of fixed-precision formats.

    For example, say you used six decimal digits of precision. One-third would be .333333. But if you add one-third three times, you get .999999, not 1. That’s the nature of the beast.

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

Sidebar

Related Questions

Possible Duplicate: Dealing with accuracy problems in floating-point numbers Code: float flt = 78983636;
Possible Duplicate: Dealing with accuracy problems in floating-point numbers I was quite surprised why
Possible Duplicate: Why is floating point arithmetic in C# imprecise? I have been dealing
Possible Duplicates: Why does 99.99 / 100 = 0.9998999999999999 Dealing with accuracy problems in
Possible Duplicate: Elegant workaround for JavaScript floating point number problem If I perform the
Possible Duplicate: How do I make a request using HTTP basic authentication with PHP
Possible Duplicate: How do I do multiple assignment in MATLAB? When dealing with cell
Possible Duplicate: Dealing with iPad Mini screen size I want to develop app for
Possible Duplicate: Is there some ninja trick to make a variable constant after its
Possible Duplicate: Can you write object oriented code in C? Hi, can someone point

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.