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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:44:11+00:00 2026-05-22T02:44:11+00:00

Greetings, I can’t believe I’m asking such a basic question, but it doesn’t make

  • 0

Greetings,

I can’t believe I’m asking such a basic question, but it doesn’t make sense so here it is :).

In C# on Windows Phone 7 / .net, I’m trying to define a constant in a class as follows:

// error CS0266: Cannot implicitly convert type 'uint' to 'int'. 
// An explicit conversion exists (are you missing a cast?)
public const int RED = 0xffff0000;

If I put an (int) cast around it like so, I get another error:

// error CS0221: Constant value '4294901760' cannot be converted to a 'int' 
// (use 'unchecked' syntax to override)        
public const int RED = (int)0xffff0000;

But I know that my int is 32-bit, hence has a range of -2,147,483,648 to 2,147,483,647, see http://msdn.microsoft.com/en-us/library/5kzh1b5w(v=vs.80).aspx

So what gives?

Thanks in advance!

swine

  • 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-22T02:44:12+00:00Added an answer on May 22, 2026 at 2:44 am

    As you note, the range of Int32 is -2,147,483,648 to 2,147,483,647, so any number within that range can be held, but ONLY numbers within that range can be held. 4,294,901,760 is greater than 2,147,483,647, so doesn’t fit in an Int32.

    What to do about this depends on what you want to achieve. If you just want an Int32 with the bit pattern ffff0000, then as suggested use unchecked :

    int y = unchecked((int)0xffff0000);
    

    y now has the value -65536, which is that bit pattern interpreted as a signed integer.

    However! If you actually want the value 4,294,901,760 you should use a datatype appropriate to it – so UInt32.

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

Sidebar

Related Questions

Greetings! I have an issue here that i can't find. I am getting a
FFT and changing frequency and vectorizing for loop Greetings All I can increase and
Greetings, Can anybody tells how can I give image distortion effect to images like
Greetings all... I am hoping somebody can shed me some lights about the issue
Greetings, I'm in need of a way where I can execute methods on the
Greetings, I am learning rapidly about Java, however something I can really break my
Greetings, I am restyling the select element with HTML5 and jQuery. I can successfully
Greetings! I set up jQuery as a global library in IntelliJ 10.0.3 but I
Greetings, I have a large piece of software developed in Eiffel. It is possible

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.