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

The Archive Base Latest Questions

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

When I run this command in PHP, I get: Code: 2269495617392648 >> 24 Result:

  • 0

When I run this command in PHP, I get:

Code: 2269495617392648 >> 24
Result: 32

When I run it in C#.net or vb.net, I get:

Code: 2269495617392648 >> 24
Result: 135272480

PHP is correct.

The interesting thing is, that when I try to shift any number greater than int32 in .net, it yields bad results..

Every number under int32 (2147483647) yields the same results from php and c#.net or vb.net

Is there a workaround for this in .net?

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

    Strictly speaking, PHP is wrong.

    The entire bit pattern of the number 2269495617392648 is:

    1000 0001 0000 0001 1000 0010 0000 0001 1000 0001 0000 0000 1000 (2269495617392648)
    

    Right shifting this 24 times gets you:

    0000 0000 0000 0000 0000 0000 1000 0001 0000 0001 1000 0010 0000 (135272480)
    

    This is the bit pattern for 135272480, not 32.

    What’s going on in PHP apparently is that the number 2269495617392648 is being truncated to 538447880 by perserving only the lower 32 bits. Note that the number 2269495617392648 is much too big to fit in a 32-bit integer, signed or unsigned.

    Right shifting the truncated bits 24 times gives us 32.

    Before truncation to 32-bits:
    1000 0001 0000 0001 1000 0010 0000 0001 1000 0001 0000 0000 1000 (2269495617392648)
    
    After truncation to 32-bits:
    0010 0000 0001 1000 0001 0000 0000 1000 (538447880)
    
    Right shifting the truncated bits by 24 bits:
    0000 0000 0000 0000 0000 0000 0010 0000 (32)
    

    You have alluded to this problem when you said:

    The interesting thing is, that when I
    try to shift any number greater then
    int32 in .net it yields bad results..

    It gives you bad results because some bits are being chopped off in order to fit in 32 bits.

    If you’re porting from PHP to C# and need to preserve this behavior, you need to manually truncate the bits by using 2269495617392648 & 0xffffffff instead of just 2269495617392648 (see jcomeau_ictx’s answer). But be aware that there is an issue of bit truncation going on in your PHP code. I’m not certain if it’s intentional or not.

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

Sidebar

Related Questions

I have this command that I run everyday via cron: find /home/get/public_html/videos -daystart -maxdepth
When I try to run this page (video.php), I get the following error: Parse
I have this command that I run every 24 hours currently. find /var/www/html/audio -daystart
I am trying to run a Python program using PHP. Here's the code $command
How do I run this command with subprocess? I tried: proc = subprocess.Popen( '''ECHO
I can run this command in SqlManager to detach the db ALTER DATABASE mydb
How can I run this on linux command line when my username has an
I am trying to run this dreadfully simple command in Bash java -cp nasa-top-secret.jar
I want to do this: run a command capture the output select a line
when I call Application.Run() on a form, this command halts the program until the

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.