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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:46:12+00:00 2026-06-11T22:46:12+00:00

float a = 0; while (true) { a++; if (a > 16777216) break; //

  • 0
float a = 0;
while (true)
{
    a++;
    if (a > 16777216)
        break; // Will never break... a stops at 16777216
}

Can anyone explain this to me why a float value stops incrementing at 16777216 in this code?

Edit:

Or even more simple:

float a = 16777217; // a becomes 16777216
  • 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-11T22:46:13+00:00Added an answer on June 11, 2026 at 10:46 pm

    Short roundup of IEEE-754 floating point numbers (32-bit) off the top of my head:

    • 1 bit sign (0 means positive number, 1 means negative number)
    • 8 bit exponent (with -127 bias, not important here)
    • 23 bits “mantissa”
    • With exceptions for the exponent values 0 and 255, you can calculate the value as: (sign ? -1 : +1) * 2^exponent * (1.0 + mantissa)
      • The mantissa bits represent binary digits after the decimal separator, e.g. 1001 0000 0000 0000 0000 000 = 2^-1 + 2^-4 = .5 + .0625 = .5625 and the value in front of the decimal separator is not stored but implicitly assumed as 1 (if exponent is 255, 0 is assumed but that’s not important here), so for an exponent of 30, for instance, this mantissa example represents the value 1.5625

    Now to your example:

    16777216 is exactly 224, and would be represented as 32-bit float like so:

    • sign = 0 (positive number)
    • exponent = 24 (stored as 24+127=151=10010111)
    • mantissa = .0
    • As 32 bits floating-point representation: 0 10010111 00000000000000000000000
    • Therefore: Value = (+1) * 2^24 * (1.0 + .0) = 2^24 = 16777216

    Now let’s look at the number 16777217, or exactly 224+1:

    • sign and exponent are the same
    • mantissa would have to be exactly 2-24 so that (+1) * 2^24 * (1.0 + 2^-24) = 2^24 + 1 = 16777217
    • And here’s the problem. The mantissa cannot have the value 2-24 because it only has 23 bits, so the number 16777217 just cannot be represented with the accuracy of 32-bit floating points numbers!
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: def paintEvent(self, paintEvent): self._painter.begin(self) try: while True: color, rectangle =
Here is my code while (true) { gg = this.CreateGraphics(); b1 = new SolidBrush(Color.Red);
I receive TypeError: Can't convert 'float' object to str implicitly while using Gambler.pot +=
Here is my Java code: Scanner userInput = new Scanner(System.in); while (true) { //
I'm learning Python-this gives me an IO error- f = open('money.txt') while True: currentmoney
I'm retrieving a float value from a mysql database on a php page (2.5,
Can you help me clarify the usages of the float primitive in Java? My
Given a float[n] inputdata to pass to the OpenCL kernel, could anyone enlighten me
Using: HTC Legend and HTC Salsa I'm calculating the speed using: while(true) { try
I have a function like this: List<float> myList = new List(float); public void numbers(string

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.