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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:51:16+00:00 2026-05-29T05:51:16+00:00

Look at this sample C code (extracted a test case as an example): main()

  • 0

Look at this sample C code (extracted a test case as an example):

main() {
  unsigned long a, b;
  int c;
  c = 32;
  a = 0xffffffff << 32;
  b = 0xffffffff << c;
  printf ("a=%x, b=%x\n", a, b);
}

Prints: a=0, b=ffffffff

I cannot understand why b is not zero, just like a. I tested this on Microsoft C and GCC.

Update: I fixed the stupid typo (should have been << c and not << b of course). But my question still stands, e.g. the result is still the same.

  • 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-29T05:51:17+00:00Added an answer on May 29, 2026 at 5:51 am

    In C it is undefined behavior to left shift more than the width of the promoted operand.

    (C99, 6.5.7p3) “If the value of the right operand is negative or is greater than or equal to the width of the promoted left operand, the behavior is undefined.”

    I assume in the examples below int and unsigned int types are 32-bit.

    The type of an unsuffixed hexadecimal integer constant is the first in the corresponding list in which its value can be represented: int, unsigned int, long, unsigned long, long long, unsigned long long.

    So here 0xFFFFFFFF is of type unsigned int and 0xFFFFFFFF << 32 is undefined behavior.

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

Sidebar

Related Questions

Have a look a this simple example. I don't quite understand why o1 prints
i've a huge problem. Take a look to this sample code private sub FUNCTION1()
Look at this sample code: <a class=change href=# id=swap01><img src=off.gif></a></div> <a class=change href=# id=swap02><img
I have a query on this. Please look at the sample code below: UIButton
See this code example: http://jsfiddle.net/Z2BMK/ Chrome/IE8 look like this Firefox looks like this My
I have some html code that look like this sample here : <html> <body>
Have a look at this very simple example WPF program: <Window x:Class=WpfApplication1.Window1 xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
I have a problem with internet explorer 6 and 7, please look this example
look at this code, <head> <meta http-equiv=Content-Type content=text/html; charset=utf-8 /> <script> function change() {
This is the sample code for web services which am trying to implement .

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.