Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

89
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda