开发者

Is there a builtin Mathematica function to read hexadecimals in 0-9,a-f format?

开发者 https://www.devze.com 2023-03-04 09:13 出处:网络
Is there a builtin Mathematica function that parses strings representing numbers in hexadecimal form, e.g. \"89ab\"?

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 wi开发者_如何学运维th error checking that I just cannot find.


FromDigits[] can already work with strings.

In[7]:= FromDigits["89ab", 16]

Out[7]= 35243
0

精彩评论

暂无评论...
验证码 换一张
取 消