MATLAB Answers


Convert 32 bit HEX to signed floating point

Asked by antlhem
on 1 Nov 2017
Latest activity Edited by Tobias Huth on 9 Apr 2018
So far I use the function hexsingle2num to convert a double type number (i.e. 41c1999a = 24.200000762939453) but when I want to use the same to convert ffffffff it gives me NaN, then I have to manually use nhex2dec('ffffffff',32) = -1 (correct answer),same with another example C0728F5C = -3.79. What I am looking for is a way to automatise this process since I have thousands of values. Is there a function in matlab that includes the conversion of HEX to SIGNED floating point?


Sign in to comment.

1 Answer

Answer by Maitreyee Mordekar on 13 Nov 2017
 Accepted Answer

By hexsingle2num function I assume that you are referring to the following File Exchange submission:
This is one of the several submissions in MATLAB File Exchange on MATLAB Central which is a forum for our product users to interact, exchange information and knowledge, without MathWorks' involvement. You may contact the author of this submission directly for specific questions about the implementation.
However, you can obtain the same results using the following function:
Also, if you still need a way to convert hexstring to double precision number then you can consider using hex2num:
Hope that helps!

  1 Comment

Works great, thanks a lot!

Sign in to comment.