Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Convert a hexadecimal string to a real number
ResourceFunction["HexStringToReal"][s] gives the machine double number corresponding to the hexadecimal string s, using 11 bits for the exponent. | |
ResourceFunction["HexStringToReal"][s,{e,prec}] computes the real number in precision prec, taking e bits for the exponent field. |
Find the number for a hex‐encoded machine float:
In[1]:= |
Out[1]= |
Translate hex‐encoded string to a software float:
In[2]:= |
Out[2]= |
Check that it is not a machine number:
In[3]:= |
Out[3]= |
The input form will also show that it has an associated precision:
In[4]:= |
Out[4]= |
Requesting more precision than is present in the hexadecimal representation will lead to padding with zero bits, which will appear as arbitrary digits in decimal form:
In[5]:= |
Out[5]= |
Wolfram Language 11.3 (March 2018) or above
This work is licensed under a Creative Commons Attribution 4.0 International License