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

164
Views
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 answers
Answer question

0

Use BigInt:

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