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

86
Vistas
Arithmetic right shift difference between do it once and do through loop

I don't know why the result of two arithmetic right are different. Can you shed light on this problem?

x=-93242
for (let i=0; i<40; i++) x >>= 1;
// now x is -1

y=-93242
y>>=40;
// now y is not -1
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Javascript only supports bit operations for upto 32-bits. Since you are trying to shift y to the right by 40-bits it's returning y>>=8 instead. It will return -1 if you shift it to the right by 31 bits.
Since x is being shifter right only once every iteration, it stays at -1 because -1>>=1 will always be -1.

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