Convert the hexadecimal representation of a binary double-precision number back into a double

1 vue (au cours des 30 derniers jours)
How can I convert a double-precision hexadecimal back into a double?
That is, given s, created from the double x as such:
s = sprintf('%bx',x)
How can I recover x?

Réponse acceptée

Fangjun Jiang
Fangjun Jiang le 3 Nov 2011
>> x=rand
x =
0.126986816293506
>> s = sprintf('%bx',x)
s =
3fc0411a9f807b7c
>> y=hex2num(s)
y =
0.126986816293506
  1 commentaire
Matthew Simoneau
Matthew Simoneau le 3 Nov 2011
That's it! I tried this and thought it wasn't working, but I had previously set "format hex". Thanks.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by