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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:34:56+00:00 2026-06-09T16:34:56+00:00

Here, i subtract 128.0 and 129.0 from a float variable 2M times. #include stdafx.h

  • 0

Here, i subtract 128.0 and 129.0 from a float variable 2M times.

#include "stdafx.h"
#include<stdlib.h> //is this the problem? Or am i doing something wrong?
int main()
{

float d1=3.0e9;
printf("\n before: %f \n",d1);
for(int i=0;i<2000000;i++) d1=d1-128.0; //doesnt change!    
printf("\n after : %f \n",d1);
for(int i=0;i<2000000;i++) d1=d1-129.0; //does change!
printf("\n after2: %f \n",d1);

//is 129 is the minimum step for sub/add ? Isnt this wrong? 
//Is this about exponential part 10^9 ?
getchar();
return 0;
 }

Output:

enter image description here

Question: Why this float does not change by adding/subbing by operands smaller then 129? Because i choose the initial float value 3.0e9 ?

When i choose initial value 3.0e10, both initialization and both subtractions dont work.

When i choose initial value 3.0e8, minimum change is 17. So 16 doesnt change. 🙁

So, thanks for answers, . When initial value get smaller, minimum step gets smaller according to precision.

VC++ 2010 express . windows xp 32 bit. pentium-m

  • 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-09T16:34:57+00:00Added an answer on June 9, 2026 at 4:34 pm

    We can understand what’s going on by looking at the anatomy of a 32-bit float. The value 3.0E9 in IEEE754 format is 0x4F32D05E, with exponent value 31 (you can use this online calculator to find the value).

    Now we have 23 sub-unity binary digits left for the mantissa. That means that the smallest increment, i.e. the difference between to adjacent values of the mantissa, is a number with binary scale 31 − 23 = 8. Since 128 is 27, we see that it is just small enough to fall off the end of the mantissa, while 129 is large enough to be visible.

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

Sidebar

Related Questions

Got this code from here http://www.irunmywebsite.com/raphael/drawtool2.php . Runs great in IE when I tested
I had a look at this question here . The problem with this question
Here's the description of this problem: You are given two integers a and b.
I want to subtract 18 years from a VB date object. Here's the code
Here is the code in a function I'm trying to revise. This example works
Here is what I am currently doing. PHP echo's out the recent post in
Here is the script I'm using, copied directly from Google: <script type=text/javascript> var _gaq
Is it possible to subtract a color from another one ? Example (correct me
You can add and subtract 1 from my cell.textLabel.text . I am adding 1
What I am trying to do is to subtract 7 hours from a date.

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.