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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:45:43+00:00 2026-05-26T00:45:43+00:00

I was trying to loop through all possible values of a float like this:

  • 0

I was trying to loop through all possible values of a float like this:

float i = 0.0F;
float epsilon = float.Epsilon;
while (i != float.MaxValue) {
    i += epsilon;
}

but after reaching the value 2.3509887E-38F it stops increasing.

float init = 2.3509887E-38F;
float f = (init + float.Epsilon);
Console.WriteLine(f == init);

I’m just curious, can anyone explain exactly why?

So, I can add epsilon to a float 16777216 times before the rounding error, and that number looks awfully familiar (2^24).

  • 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-26T00:45:44+00:00Added an answer on May 26, 2026 at 12:45 am

    There’s a lot of very wooly thinking here. Floating point numbers are not “imprecise”. There is no “may”. It’s a deterministic system, like anything else on a computer.

    Don’t to analyze what’s going on by looking at decimal representations. The source of this behavior is completely obvious if you look at these numbers in binary or hexadecimal. Let’s use binary:

    float.Epsilon is b1.0 x 2^-149
    2.3509887E-38 is b1.0 x 2^-125
    

    If we add these two numbers together, the infinitely precise (unrounded) sum is:

    b1.000 0000 0000 0000 0000 0000 1 x 2^-125
    

    Note that the significand of this sum is 25 bits wide (I’ve grouped the binary digits into sets of four to make them easier to count). This means that it cannot be represented in single-precision, so the result of this sum is not this value, but instead this value rounded to the closes representable float. The two closest representable numbers are:

    b1.000 0000 0000 0000 0000 0000 x 2^-125
    b1.000 0000 0000 0000 0000 0001 x 2^-125
    

    Our number is exactly halfway in between them. Since you haven’t set the rounding mode in your program, we are in the default rounding mode, which is called “round to nearest, ties to even”. Because the two options are equally close, the tie is broken by choosing the one whose lowest-order bit is zero. Thus, 2^-125 + 2^-149 is rounded to 2^-125, which is why “it stops increasing”.

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

Sidebar

Related Questions

I'm trying to use Linq to loop through all fonts in the %windir%\Fonts folder
I'm trying to write a unit test that will loop through all action methods
I'm trying to loop through the results from the Last.fm API but it's not
I'm trying to loop through items of a checkbox list. If it's checked, I
I am trying to loop through a directory of text files and combine them
In the below code I'm trying to loop through each child node and append
So I have an XML file that I am trying to loop through in
I am having problems with my JScript code. I am trying to loop through
I'm using smarty for my site, and I'm trying to loop through an array
I'm trying to use openmp to multithread a loop through std::set. When I write

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.