Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

170
Visualizações
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 Respostas
Responde à pergunta

0

Use BigInt:

let toReturn = (BigInt('0x' + bytesA) & BigInt('0x' + bytesB)).toString(16);
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda