Sign in to follow this  
Followers 0
_Pavel_

NJ and IEEE 754 float

3 posts in this topic

Dear Colleagues,

could you please give a tip for the following

Via RS485 non-standard protocol I receive from a slave device some data which is presented as IEEE754 24-bit float. Moreover I receive a byte array

E.g. I receive byte[0] = 0x41 byte[1] = 0xF0 byte[2] = 0x00, which is IEEE754 representation of 30.00

So how do I obtain the REAL value from byte array?

Searched through Instructions Reference Manual and didn't find no suitable instructions. No word about conversion byte array to IEEE754 float

Thanks!

Share this post


Link to post
Share on other sites

IEEE754 24-bit is actually a 32-bit value for what I understand. 24-bit for significant digits, and remaining 8-bit is the exponent bits.

So from your data, the actual data should be :

byte[0] = 0x41 --> 3rd Significant bits
byte[1] = 0xF0 --> 2nd Significant bits
byte[2] = 0x00 --> 1st Significant bits
byte[3] = 0x00 --> Exponent bits

Now there is a function which called AryByteTo, which can convert Byte Arrays to almost anything. The only issue you have to solve is to rearrange the byte order, into something like this:

byte[0] = 0x00 --> Exponent bits
byte[1] = 0x00 --> 1st Significant bits
byte[2] = 0xF0 --> 2nd Significant bits
byte[3] = 0x41 --> 3rd Significant bits

To make my point clear, here's a screenshot of a test :

Capture.JPG.1b207aa8b167da08e28291be5cc9

Edited by innoaloe
1 person likes this

Share this post


Link to post
Share on other sites

innoaloe, thank you so much!

24-bit IEEE has only 15 bit mantissa ( 1 bit sign + 8 bit exponent + 15 bit mantissa), it's just less accurate than 32-bit IEEE, which has 23-bit mantissa

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0