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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:35:41+00:00 2026-05-14T00:35:41+00:00

I have the following problems: First: I am trying to do a 32-spaces bitwise

  • 0

I have the following problems:

First: I am trying to do a 32-spaces bitwise left shift on a large number, and for some reason the number is always returned as-is. For example:

echo(516103988<<32); // echoes 516103988

Because shifting the bits to the left one space is the equivalent of multiplying by 2, i tried multiplying the number by 2^32, and it works, it returns 2216649749795176448.

Second: I have to add 9379 to the number from the above point:

printf('%0.0f', 2216649749795176448 + 9379); // prints 2216649749795185920 

Should print: 2216649749795185827

  • 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-14T00:35:42+00:00Added an answer on May 14, 2026 at 12:35 am

    Based on Pascal MARTIN’s suggestions, i tried both the BCMath and the GMP extension and came up with the following solutions:

    With BCMath:

    $a = 516103988;
    $s = bcpow(2, 32);    
    $a = bcadd(bcmul($a, $s), 9379);
    echo $a; // works, echoes 2216649749795185827
    

    With GMP:

    $a = gmp_init(516103988); 
    $s = gmp_pow(gmp_init(2), 32); 
    $a = gmp_add(gmp_mul($a, $s), gmp_init(9379)); 
    echo gmp_strval($a);  // also works
    

    From what i understand, there is a far greater chance for BCMath to be installed on the server then GMP, so i will be using the first solution.

    Thanks 🙂

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

Sidebar

Related Questions

I'm trying to use client_side_validations gem, but have some problems. First, I have in
I'm having problems when trying to compile the following code: I first tried compiling
all! I have the following problem: I have 2 simple tables. The first one,
I have the same problem that is listed in the following thread. WSDL first
I have a following problems with eclipse, when I installed ClearCase plugin from this
I have following piece of code: It compiles without problems under gcc-3.4, gcc-4.3, intel
I have problems with following code: http://lisper.ru/apps/format/96 The problem is in normalize function, which
I have the following html/css that is causing problems in Firefox 1.5 and 2,
I have the following loop which is giving me problems $(#divResults).append('<table>'); $.each( results.d, function(
I am having problems with passing arguments to new threads, I have the following

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.