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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:14:05+00:00 2026-05-26T23:14:05+00:00

In looking at this question I was trying to figure out this function _shl:

  • 0

In looking at this question I was trying to figure out this function

_shl: function (a, b){
  for (++b; --b; a = ((a %= 0x7fffffff + 1) & 0x40000000) == 0x40000000 ? a * 2 : (a - 0x40000000) * 2 + 0x7fffffff + 1);
  return a;
}

I figured out the javascript syntax and also found an uncompressed version of the function used in a md5 javascript implementation

function shl1(a) {
  a=a%(0x7fffffff+1);
  if (a&0x40000000==0x40000000)
  {
    a-=0x40000000;  
    a*=2;
    a+=(0x7fffffff+1);
  } else
    a*=2;
  return a;
}

function shl(a,b) {
  a=integer(a);
  b=integer(b);
  for (var i=0;i<b;i++) a=shl1(a);
  return a;
}

My question is what is significant about 0x40000000 and 0x7fffffff. I somewhat understand the idea of a bitwise shift, but I am lost about the importance of these two numbers.

  • 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-26T23:14:06+00:00Added an answer on May 26, 2026 at 11:14 pm

    The 0x7fffffff is, in binary, a 0 followed by 31 1s. Adding one to it gives 0x80000000, a 1 followed by 31 0s. I don’t know why the direct constant isn’t there. %ing by 0x80000000 will cut off the 32nd and all higher bits.

    The 0x40000000 is, in binary, a 0, a 1, and then 30 0s. &ing with 0x40000000 and checking for equality to 0x40000000 checks whether that 31st bit (counting from the right this time) is set.

    As far as I can tell, the section (a - 0x40000000) * 2 + 0x7fffffff + 1) should be the same as a. Not sure why the extended code is required.

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

Sidebar

Related Questions

While looking up the answer to this question: Why is an out parameter not
Arising out of this question, I'm looking for an elegant (ruby) way to compute
I checked this question , but it's not what I'm looking for. I'm trying
Since I started writing this question, I think I figured out the answers to
As the question already suggests, I'm trying to figure out, if it's possible to
I'm looking for advice, and maybe a few examples. I'm trying to figure out
I was looking at this question. Basically having a leading zero causes the number
I just finished looking at this question: https://stackoverflow.com/questions/753122/which-cloud-computing-platform-should-i-choose But, I am not certain what
Thanks for looking at this question. I wanted to know how can I use
I was looking at this question: How to remove duplicate elements from an xml

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.