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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:38:41+00:00 2026-05-30T08:38:41+00:00

If I write this declaration: unsigned ux = 2147483648; (2 31 ), will the

  • 0

If I write this declaration:

unsigned ux = 2147483648;

(231), will the C compiler treat 2147483648 as an unsigned or signed value?

I’ve heard that constant values are always treated as signed, but I don’t think that’s always right.

  • 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-30T08:38:42+00:00Added an answer on May 30, 2026 at 8:38 am

    The value of an unsuffixed decimal constant such as 2147483648 depends on the value of the constant, the ranges of the predefined type, and, in some cases on the version of the C standard you’re using.

    In C89/C90, the type is the first of:

    • int
    • long int
    • unsigned long int

    in which it fits.

    In C99 and later, it’s the first of:

    • int
    • long int
    • long long int

    in which it fits.

    You didn’t tell us what implementation you’re using, but if long int is 32 bits on your system, then 2147483648 will be of type unsigned long int if you have a pre-C99 compiler, or (signed) long long int if you have a C99 or later compiler.

    But in your particular case:

    unsigned ux = 2147483648;
    

    it doesn’t matter. If the constant is of type unsigned int, then it’s already of the right type, and no conversion is necessary. If it’s of type long long int (as it must be in C99 or later, given 32-bit long), then the value must be converted from that type to unsigned. Conversion from a signed type to an unsigned type is well defined.

    So if unsigned is wide enough to represent the value 2147483648, then that’s the value that will be stored in ux. And if it isn’t (if unsigned int is 16 bits, for example), then the conversion will result in 0 being stored in ux.

    You can exercise some control over the type of a constant by appending a suffix to it. For example, 2147483648UL is guaranteed to be of some unsigned type (it could be either unsigned int or unsigned long int).

    Incidentally, your question’s title is currently “About Class Cast.(if I write unsigned ux=2147483648(2 to the 31 st))”, but your question has nothing to do with classes (which don’t exist in C) or with casts. I’ll edit the question.

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

Sidebar

Related Questions

How can I write this in such a way that $counter value is 1
How comes that it is possible to write this.class in the fields declaration of
I am using a 3rd party library that has a declaration like this: typedef
I write this in api v2: map.enableGoogleBar(); I want to using v3, but I
I could probably write this myself, but the specific way I'm trying to accomplish
I would like to write this as a user defined function: private double Score(Story
Say I write this: from subprocessing import Popen, STDOUT, PIPE p = Popen([myproc], stderr=STDOUT,
Sure I could write this myself, but before I go reinventing the wheel is
How to write this in C#.NET, I have not been encountered using the ^
would someone please write this code: this.Loaded += (s, e) => this.loaded = true;

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.