How to convert an array of bytes to IEEE 754 single-precision float?
31 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Minh Tran
am 1 Apr. 2019
Kommentiert: Minh Tran
am 1 Apr. 2019
I'm using Matlab R2007b.
I have an array
[65 227 216 168]
which represents the hexadecimal digits
0x41E3D8A8
that I'd like to interpret as a single-precision IEEE 754 float. The value that float takes on should be approximately 28.4808.
I'm able to use several online calculators to convert 0x41E3D8A8 to ~28.4808 but I can't seem to get that value in Matlab, starting from the array representation of that Hex value. I tried:
single(typecast(uint8([65 227 216 168]), 'uint32')) % Returns 2.8328e+009
0 Kommentare
Akzeptierte Antwort
James Tursa
am 1 Apr. 2019
Try this:
>> swapbytes(typecast(uint8([65 227 216 168]),'single'))
ans =
single
28.4808
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Numeric Types finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!