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?
3 Answers
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...
}
You can use the parseInt function:
var n = parseInt("10", 16); // parse 10 as base 16 (hex).
-Oisin