0

following one of he solutions in this, I tried to convert a hex color string into numerical RGB using the following code:

let bigint = parseInt(hex.substring(2), 16);

let r = (bigint >> 16) & 255;
let g = (bigint >> 8) & 255;
let b = bigint & 255;

return {r, g, b};

On Chrome everything works fine, on Firefox however, the r value is not what I expected for some colors.

An example:

#729AC2 in Chrome yields (114, 154, 194), in Firefox (2, 154, 194).

I have tried various other conversion methods in the thread. Most of them I got to work on Chrome as well, in however in Firefox the "r" value is NaN.

What am I not seeing?

Nimantha
  • 6,405
  • 6
  • 28
  • 69
  • The code gives the same in chrome and FF, the only difference is, that you accidentally typed `.substring(2)` in FF, which also makes no sense (given there is only one `#` at the start to omit). – ASDFGerte Sep 02 '22 at 22:02

0 Answers0