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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:04:22+00:00 2026-06-12T05:04:22+00:00

I have code that sets a default value of a cell to the value

  • 0

I have code that sets a default value of a cell to the value of the cell above multiplied by 100:

const int DUCKBILL_MULTIPLIER = 100;
. . .
cellValue = dataGridViewPlatypi.Rows[args.RowIndex - 1].Cells[0].Value;
if (Convert.ToInt32(cellValue) > 0)
{
    int nextDefaultVal = Convert.ToInt32(cellValue) * DUCKBILL_MULTIPLIER;
    cellValue = nextDefaultVal;
}
prevVal = cellValue == null ? string.Empty : cellValue.ToString();
. . .
dataGridViewPlatypi.Rows[args.RowIndex].Cells[args.ColumnIndex].Value = prevVal;

But once the value above gets to be 1000000000 (1 billion), the next value is 1215752192 (1,215,752,192 or approximately 1.2 billion) instead of 100 billion.

I understand that the max int value is 2,147,483,647 (approximately 2.1 billion); so why is the next value 1,215,752,192 instead of 2,147,483,647?

BTW, these vals are larger than the app will ever need to be, but I found this in testing “extreme” cases.

  • 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-12T05:04:23+00:00Added an answer on June 12, 2026 at 5:04 am

    Because multiple overflows are happening. Every time 2,147,483,647 is reached, the count starts over. Now, you have to keep in mind that it overflows to -2,147,483,648. So we have to take into account the whole Int32 range, which is 4,294,967,296 (it can be calculated from (Int64)Int32.MaxValue + 1 - Int32.MinValue or simply 2^32.

    The math:

    (1 billion * 100) % (4,294,967,296) = 1215752192
    

    Proof of concept in C# code:

    var range = (Int64)Int32.MaxValue + 1 - Int32.MinValue;
    Int64 val = 100000000000 % range;
    Console.WriteLine(range);
    Console.WriteLine(val);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some code that sets the lang var to the site default language.
I have the following code in my codebehind Page_Load function that sets the default
I have some code that sets up a dictionary with some defualt values for
I have a code that sets a new repeating alarm (on production I'll use
I have the following code that sets a background if user has uploaded to
I have code in global.asax that sets some things in cache with CacheItemRemovedCallback. When
I have some setup code in my functions.php file that sets permalinks and adds
I need help with my C code. I have a function that sets a
I have the following Javascript code that works perfectly: $(document).ready(function() { $(#Select1).setDefault(); $(#Select2).setDefault(); $(#Select3).setDefault();
I have code that generates a List<string[]> variable but can't quite figure out how

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.