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

86
Views
Different calculation result

Explain to me why the result of the following calculation is different:

Python:

tmp = 4235635936 << 0 #4235635936

JS

let tmp = 4235635936 << 0 // -59331360

Question - how do I get the same result in python as in js ?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

The binary representation for both numbers is the same. One is signed, the other is unsigned.

>>> struct.pack("<i", -59331360)
b'\xe0\xacv\xfc'
>>> struct.pack("<I", 4235635936)
b'\xe0\xacv\xfc'
>>>
about 4 years ago · Juan Pablo Isaza Report

0

in JS, the bitwise operators and shift operators operate on 32-bit ints, and your example overflows the 32-bit capacity.

In Python there's no capacity limit for integers, so you get the actual value.

about 4 years ago · Juan Pablo Isaza Report
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!