Code covered by the BSD License  

Highlights from
hexsingle2num

5.0

5.0 | 9 ratings Rate this file 18 Downloads (last 30 days) File Size: 2.32 KB File ID: #6927

hexsingle2num

by Mark Lubinski

 

15 Feb 2005 (Updated 22 Jun 2005)

hex2num for single.

| Watch this File

File Information
Description

hexsingle2num converts a single precision IEEE hexadecimal string to a number.

hexsingle2num is a version of hex2num which works with single precision floats. Currently MATLAB hex2num converts to double precision floats.

HEXSINGLE2NUM(S), where S is a 8 character string containing a hexadecimal number, returns a double type number equal to the IEEE single precision floating point number it represents. Fewer than 8 characters are padded on the right with zeros.
 
If S is a character array, each row is interpreted as a single precision number (and returned as a double).
 
NaNs, infinities and denorms are handled correctly.
 
Example:
  hexsingle2num('40490fdb') returns Pi.
  hexsingle2num('bf8') returns -1.

Acknowledgements
This submission has inspired the following:
singlehex2num, Simulink hexsingle2num block
MATLAB release MATLAB 7.0.1 (R14SP1)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (9)
12 May 2005 Reinhold Habeck

Superb, exactly what I needed to read binary files with REAL*4 floating numbers produced by a FORTRAN application. It helps me to save file space, because I don't need to store data in REAL*8.

This version should be included in the MATLAB library as an add-on to the function hex2num.

29 Jan 2006 John Winger

Nice function. I needed to be able to convert a byte stream into floats. This is the only way I have found to do it.

28 Sep 2007 Seung Ho Ok

Good job! I'm looking for this function!!!

18 Jul 2008 Daniel Martin

just What I needed!! I agree with the last comment. This function should be included in Matlab. hex2num only works with double precion numbers!!

Great job

30 Jul 2008 Steven Wright

Very nice, thanks for saving me the effort.

07 Mar 2009 Jaykumar Shah

Simply Gr8...!!!!!!!!
Thanks

17 May 2011 Tanya

Exactly what I have been looking for!!!

26 Aug 2011 Andrey Krishkevich

Just what I've been looking for!

07 Feb 2012 neea  
Please login to add a comment or rating.
Updates
22 Jun 2005

Fixed bug with underflow (bug found by Matthias Noell).

Tag Activity for this File
Tag Applied By Date/Time
strings Mark Lubinski 22 Oct 2008 07:41:17
hex2num Mark Lubinski 22 Oct 2008 07:41:17
single Mark Lubinski 22 Oct 2008 07:41:17
ieee Mark Lubinski 22 Oct 2008 07:41:17
hexadecimal Mark Lubinski 22 Oct 2008 07:41:17
utilities Mark Lubinski 22 Oct 2008 07:41:17
string manipulation Mark Lubinski 22 Oct 2008 07:41:17

Contact us at files@mathworks.com