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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:49:43+00:00 2026-06-01T19:49:43+00:00

This feels like a stupid question, but I can’t seem to see the answer.

  • 0

This feels like a stupid question, but I can’t seem to see the answer. I have an UInt64, which is supposed to have a max value of

UInt64.MaxValue 18446744073709551615

However, when I try to assign a modest-sized number, I get this overflow error of “The operation overflows at compile time in checked mode”. If I wrap it in an “unchecked” block then it compiles, and runs as if this variable is zero:

UInt64 value1 = 1073741824 * 8; // Compile error CS0220
UInt64 value2 = 8589934592;     // Actual value - no error

Why is this happenning?

  • 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-01T19:49:44+00:00Added an answer on June 1, 2026 at 7:49 pm

    Because:

    UInt64 value1 = 1073741824 * 8;
    

    Is doing the arithmetic as a signed 32-bit integer, then converting it to an ulong. Try:

    UInt64 value1 = 1073741824UL * 8;
    

    The UL means that the literal is of an unsigned long. See section 2.4.4 of the C# Specification for more on literal suffixes:

    If the literal is suffixed by UL, Ul, uL, ul, LU, Lu, lU, or lu, it is of type ulong

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

Sidebar

Related Questions

This feels like such a stupid question, but how can I find a string
I feel like this is a stupid question, but I can't think of a
This feels like a really basic question, but I can't figure it out anyway..
This may seem like a basic/stupid/obviously-answered question, but I wanted to check: why use
I feel stupid asking this question, but I can not find a clear answer
This is a stupid question, it feels like one. But mental block is bad
I feel really stupid for asking a question like this, but I cannot seem
This feels like a stupid question, but is there a simple control for WPF
This is probably a stupid question but I can not seem to either remember
OK, this feels like an idiot question, but I'm stuck - I don't know

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.