Clear Filters
Clear Filters

How to convert a file containing real numbers into binary/hexadecimal?

2 views (last 30 days)
I want to convert whole file of real numbers having atleast 1000 data points into binary/hex using some function or program. Plz help

Accepted Answer

Walter Roberson
Walter Roberson on 19 Jun 2016
num2hex() is the routine to use to see the hex representation of the IEEE 754 bit pattern for float or double.

More Answers (2)

Azzi Abdelmalek
Azzi Abdelmalek on 19 Jun 2016
Edited: Azzi Abdelmalek on 19 Jun 2016
You can use dec2bin and dec2hex function

MEENU SAINI
MEENU SAINI on 19 Jun 2016
but there is some problem in the converted data. I have converted a file containing 1000 real numbers to hexadecimal using this function num2hex(). The real numbers are like:
-0.0128380000000000
-0.0142530000000000
-0.0080360000000000
-0.0120290000000000
-0.0136970000000000
-0.0268890000000000
-0.0320450000000000
-0.0295180000000000 & so on upto 1000.
--
The converted hex file is looking like:
bf8a4acf312b1b37
bf8d30ad46f587d7
bf80752da98676a7
bf88a2a90cd423d9
bf8c0d2c386d2ed8
bf9b88ca3e7d1351
bfa06833c60029f1
bf9e39f77292c493
--
but I think it should be like:
0xbc52567a
0xbc69856a
0xbc03a96d
0xbc451548
0xbc606962
0xbcdc4652
0xbd03419e
--
Is there any solution to this? Plz reply
  3 Comments
MEENU SAINI
MEENU SAINI on 20 Jun 2016
Thank you Sir!! I have one more problem that after processing this converted data file, I need to convert this hex file back to real data file. So what function should I use? Plz help!

Sign in to comment.

Categories

Find more on Data Type Conversion in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!