5

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 3

12

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...
}
Sign up to request clarification or add additional context in comments.

Comments

4

You can use the parseInt function:

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

-Oisin

Comments

2

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.