Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

105
Views
Unexpected result of right shift operators NodeJS

I am aware that JS has >> apparently for signed-numbers shifts and >>> for unsigned.

I tested two simple examples in the node console:

a = 0b10000000000000000000000000000100
> a >> 31
-1
> a >>> 31
1

I've read mdn, w3schools, etc. But I expect both cases to be 1.

Also, see a 31 bit number:

a = 0b1000000000000000000000000000010;
a>>30
1 
a>>>30
1

What is the mistake?

May be related to JS reading the number as 32Bits, and using that last bit as a sign?

> (a & a).toString(2)
'-1111111111111111111111111111100'
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!