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

1 回表示 (過去 30 日間)
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?

採用された回答

Fangjun Jiang
Fangjun Jiang 2011 年 11 月 3 日
>> x=rand
x =
0.126986816293506
>> s = sprintf('%bx',x)
s =
3fc0411a9f807b7c
>> y=hex2num(s)
y =
0.126986816293506
  1 件のコメント
Matthew Simoneau
Matthew Simoneau 2011 年 11 月 3 日
That's it! I tried this and thought it wasn't working, but I had previously set "format hex". Thanks.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by