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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:07:46+00:00 2026-05-26T08:07:46+00:00

I checked the document that long = int64 has range more than 900,000,000,000,000 Here

  • 0

I checked the document that long= int64 has range more than 900,000,000,000,000

Here is my code:

int r = 99;
long test1 = r*r*r*r*r;

at runtime it gives me 919,965,907 instead of the correct 9,509,900,499.

another test

long test2 = 99*99*99*99*99;

It refuses to compile, saying integer overflow.

But if i do this

long test3 = 10100200300;

This works fine.

  • 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-26T08:07:47+00:00Added an answer on May 26, 2026 at 8:07 am

    The problem is that the literal “99” is being treated as an int. If you add “L” it will treat it as a long. To fix your compilation problem:

    long test2 = 99L * 99L * 99L * 99L * 99L;
    

    And to fix the “incorrect result” caused by integer overflow:

    long r = 99;
    long test1 = r * r * r * r * r;
    

    The key point is that the expression to the right of the “=” is evaluated before the assignment to long r is done.

    There are other literal suffixes you might be interested in:

    Type    Suffix    Example
    uint    U or u    100U
    long    L or l    100L
    ulong   UL or ul  100UL
    float   F or f    123.45F
    decimal M or m    123.45M
    

    @m.edmonson, regarding your question about why it comes out to 919965907. What’s happening, is that the value is “wrapping” around int.MaxValue. You can see this with a little test program:

    int i = 99; // 99
    i *= 99;    // 9801
    i *= 99;    // 970299
    i *= 99;    // 96059601
    i *= 99;    // 919965907        should be 9509900499 but comes out to 919965907
                //                      which is (9509900499 % int.MaxValue)
    
    long k = 9509900499 % int.MaxValue;
    

    What is meant by “wrapping around”? When you exceed int.MaxValue by 1, the value “goes back” to int.MinValue.

    int j = int.MaxValue;
    j++;
    
    bool isNowMinValue = (j == int.MinValue);   // true, the value has "wrapped around"
    

    This is a bit simplistic; if you search for “integer overflow” you will get a better explanation. It’s worth understanding how integers (and other numeric types) are represented with 32 bits:

    http://en.wikipedia.org/wiki/Signed_number_representations

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

Sidebar

Related Questions

So I have the following JavaScript code: <script type=text/javascript> function clearRadioButtons() { document.getElementById(radiobutton1).checked=; //etc
Help!!! I am trying to compile a LaTeX document that has been compiled before,
I haven't checked with IE9 but I have a simple JS that utilizes document.write
I have code that creates an XML document that is difficult to read in
$(document).ready(function() { function countChecked() { var n = $(input:checked).length; $(div).text(n + (n <= 1
i use this javascript syntax for validating a checkbox... alert(document.getElementById(ctl00_ContentPlaceHolder1_Chkreg).checked); if (document.getElementById(ctl00_ContentPlaceHolder1_Chkreg).checked == false)
<input type=Checkbox checked= name=new> if I have the above html in a document, how
So i have an XML document that looks like this: <?xml version=1.0 encoding=UTF-8?> <gesmes:Envelope
I'm working on an x86 asm obfuscator that takes Intel-syntax code as a string
I've got a set of checkboxes that are added to a document via an

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.