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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:15:13+00:00 2026-05-31T23:15:13+00:00

While reflecting with ILSpy i found this line of code in the Queue<T>.Enqueue(T item)

  • 0

While reflecting with ILSpy i found this line of code in the Queue<T>.Enqueue(T item)-method:

if (this._size == this._array.Length)
{
    int num = (int)((long)this._array.Length * 200L / 100L);
    if (num < this._array.Length + 4)
    {
        num = this._array.Length + 4;
    }
    this.SetCapacity(num);
}

I’m just wondering why somebody would do this? I think it’s some kind of a integer overflow check, but why multiply first with 200L and then divide by 100L?

Might this have been a issue with earlier compilers?

  • 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-31T23:15:14+00:00Added an answer on May 31, 2026 at 11:15 pm

    Usually things first multiplied then divided by 100 are percentage calculations – Perhaps there was some const XxxPercentage = 200 or something like that in the original code. The compiler does not seem to optimize the * 200 / 100 to * 2.

    This code sets the capacity to twice its size – but if twice its size would be smaller than the original size + 4, use that instead.

    The reason it is converted to long probably is because if you multiply an integer by the “200 percent” it would overflow.

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

Sidebar

Related Questions

Sorry since this question is specific to my problem. While learning reflections i did
In this example how UpdateModel method fill person instance with formValues? I think UpdateModel
While debugging Java code that uses reflection in Eclipse, some times I need to
While l was looking over some questions about MEF, I stumbled onto this particular
Ok, this has had me stumped for a while - One of our clients
While writing MVC views I see a lot of call to Html helper method
I'm getting this error from Mono's wsdl utility while trying to process eBay's WSDL
while running following code : def v1=[]; def p=[]; v.as('x') .except(v1).sideEffect{v1.add(it)} // step 1
How to pass int,string and float to the method called using reflections ? Basically,different
I've got a problem converting an object property to string while using reflection... 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.