Effacer les filtres
Effacer les filtres

How to translate 32-bit number to float number

2 vues (au cours des 30 derniers jours)
wenlong
wenlong le 28 Juil 2016
Commenté : wenlong le 1 Août 2016
The acquired data is expressed as '6D61803F', this may be a little-endian. I translated it to '3F80616D', then I got the float number 1.002973, this was the real data!
Now I used
q = quantizer(q);
hex2num(q, '6D61803F') or hex2num(q, '3F80616D')
Both of those did not get the real one!
What's the problem?
Thanks
  3 commentaires
wenlong
wenlong le 29 Juil 2016
Modifié(e) : Walter Roberson le 29 Juil 2016
q =
DataMode = fixed
RoundMode = floor
OverflowMode = saturate
Format = [16 15]
Sorry about q = quantizer(q); it should be q = quantizer
wenlong
wenlong le 1 Août 2016
Thanks Walter!

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 29 Juil 2016
>> q = quantizer; q.quantize(1.002973)
Warning: 1 overflow(s) occurred in the fi quantize operation.
> In embedded.quantizer/quantize (line 77)
ans =
0.999969482421875
You are exceeding the range of the quantizer.
>> q.numeric2hex(1.002973)
ans =
7fff
You are providing more hex digits than fit into the quantizer.
A [16 15] quantizer is a total of 16 bits long.
I would suggest that you need
q = quantizer('mode', 'single');
hex2num(q, '3F80616D')
ans =
1.00297319889069

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by