Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
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?
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... }
Add a comment
You can use the parseInt function:
var n = parseInt("10", 16); // parse 10 as base 16 (hex).
-Oisin
Use parseInt("0x"+ string) to transform your string value into a numeric one
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.