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

  • Home
  • SEARCH
  • 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 6790611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:44:44+00:00 2026-05-26T17:44:44+00:00

Why does this loop (to 1 billion) only take a few sounds to execute

  • 0

Why does this loop (to 1 billion) only take a few sounds to execute …

for (i = 0; i < 1000000000; i++)
{

}

… but this loop (to 10 billion) takes >10 minutes?

for (i = 0; i < 10000000000; i++)
{

}

Shouldn’t it just take 30 seconds or so (3 seconds x 10)?

  • 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-26T17:44:45+00:00Added an answer on May 26, 2026 at 5:44 pm

    I guess i is a 32-bit integer variable and is therefore always smaller than 10 billion (which is more than 2^32), whereas 1 billion still fits into the 32-bit range (which ends at about 2 or 4 billion, depending on signedness). Though I don’t know how the compiler promotes this 10 billion constant, but he seems to realize the overflow issue and makes it an infite loop.

    What happens when you make i a long long int (and maybe the 10000000000 a 10000000000L, but that seems to be no problem)?

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

Sidebar

Related Questions

Does this smell? I have a few properties you can only set once. They
Ok. So I am a total beginner at Java. But why does this loop
This loop does not terminate after I type x. I'm really new to Ruby,
what does the assignment in this loop do? I don't get the array notation
why does this piece of code go into an infinite loop when I try
I have a loop on the server ( C# ) that does this: for(i=0;i<=Request.Files.Count
I have this loop running after a click(), and it does not return false
Why does this code delete only even elements within the array? I would expect
What does this instruction vector=[vector,sum(othervector)] does in matlab inside a while loop like: vector=[];
Possible Duplicates: Why does this go into an infinite loop? Things like i =

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.