tags:

views:

114

answers:

3

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
+1  A: 

You can use the parseInt function:

var n = parseInt("10", 16); // parse 10 as base 16 (hex).

-Oisin

x0n
A: 

Use parseInt("0x"+ string) to transform your string value into a numeric one

Eineki