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

163
Vistas
What's the most efficient way to execute a bitwise operation on two long hex values in JS?

I'm trying to execute an AND operation on two 128-byte hexadecimal values. Something like:

let toReturn = (parseInt(bytesA, 16) & parseInt(bytesB, 16)).toString(16);

seems to work well for values not longer than 0xfffffff. Anything more than that, and I'm starting to get incorrect values.

I've considered iterating through both values - byte after byte, but my overall code is getting a little heavy, and various 128-byte values would need to be compared 8 times in a loop, that's nested in another loop (up to 50 iterations), all that on page load.

I'm hoping to find a more efficient solution for that.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Use BigInt:

let toReturn = (BigInt('0x' + bytesA) & BigInt('0x' + bytesB)).toString(16);
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