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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:41:49+00:00 2026-05-26T21:41:49+00:00

The Standard specifies that hexadecimal constants like 0x8000 (larger than fits in a signed

  • 0

The Standard specifies that hexadecimal constants like 0x8000 (larger than fits in a signed integer) are unsigned (just like octal constants), whereas decimal constants like 32768 are signed long. (The exact types assume a 16-bit integer and a 32-bit long.) However, in regular C environments both will have the same representation, in binary 1000 0000 0000 0000.
Is a situation possible where this difference really produces a different outcome? In other words, is a situation possible where this difference matters at all?

  • 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-26T21:41:50+00:00Added an answer on May 26, 2026 at 9:41 pm

    Yes, it can matter. If your processor has a 16-bit int and a 32-bit long type, 32768 has the type long (since 32767 is the largest positive value fitting in a signed 16-bit int), whereas 0x8000 (since it is also considered for unsigned int) still fits in a 16-bit unsigned int.

    Now consider the following program:

    int main(int argc, char *argv[])
    {
      volatile long long_dec = ((long)~32768);
      volatile long long_hex = ((long)~0x8000);
    
      return 0;
    }
    

    When 32768 is considered long, the negation will invert 32 bits,
    resulting in a representation 0xFFFF7FFF with type long; the cast is
    superfluous.
    When 0x8000 is considered unsigned int, the negation will invert
    16 bits, resulting in a representation 0x7FFF with type unsigned int;
    the cast will then zero-extend to a long value of 0x00007FFF.
    Look at H&S5, section 2.7.1 page 24ff.

    It is best to augment the constants with U, UL or L as appropriate.

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

Sidebar

Related Questions

The standard specifies (23.4.4.2:5, etc.) that constructing all four ordered associative containers ( map
The standard specifies that the contents of reallocated space is undefined if the new
The ISO 1998 c++ standard specifies that not explicitly using a return statement in
The C++11 standard specifies that vwscanf is available via header <cwchar> (and therefore <wchar.h>
I have a standard Button Style applied accross my application that specifies a mouseover
I am trying to find the document that specifies the standard for pthreads. I've
From section 7.3.4.2 of the c++11 standard: A using-directive specifies that the names in
The PSR-0 ( https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md ) standard specifies that an underscore in the class name
I know the standard specifies that it is for vectors, but what about strings?
The standard explicitly states that main has two valid (i.e., guaranteed to work) signatures;

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.