Reputation: 25703
Is there a builtin Mathematica function that parses strings representing numbers in hexadecimal form, e.g. "89ab"
?
I could use
FromDigits[
ToExpression[Characters["89ab"] /.
Thread[CharacterRange["a", "f"] -> Range[10, 15]]],
16
]
or even
ToExpression["16^^" <> "89ab"]
but I'm sure there must be a more robust builtin function with error checking that I just cannot find.
Upvotes: 3
Views: 116
Reputation: 523214
FromDigits[]
can already work with strings.
In[7]:= FromDigits["89ab", 16]
Out[7]= 35243
Upvotes: 8