I have an array of string-encoded hex values. I need to convert those strings to actual hex values and then be able to compare them (using standard less-than/greater-than/equals). What is the best way to accomplish this?
+2
A:
Use the JavaScript parseInt method to convert hex string values into their integer equivalent.
For example:
var value = parseInt("FF", 16);
if (value < 256) {
// do something...
}
Jon Benedicto
2009-10-06 17:55:12
+1
A:
You can use the parseInt function:
var n = parseInt("10", 16); // parse 10 as base 16 (hex).
-Oisin
x0n
2009-10-06 17:56:29
A:
Use parseInt("0x"+ string) to transform your string value into a numeric one
Eineki
2009-10-06 18:01:06