LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Unsigned Binary to Floating Point data type

Hello,

I'm trying to perform a conversion from unsigned binary to floating point type but I'm not sure how to perform this conversion correctly. Here is the binary data structure below.

The data contains 3 words as shown where S is the sign bit, M is mantissa and Exp is the exponent. Any assistance will be appreciated. Thanks

 

Word3                  Word2           Word1

Byte2 Byte 1       Byte2Byte1     Byte2Byte1

7..0    7...0          7...0  7...0        7...0 7....0

S  M   M              M      M            M      Exp

 

 

0 Kudos
Message 1 of 8
(1,823 Views)

Hi SolPS,

 


@SolPS wrote:

The data contains 3 words as shown where S is the sign bit, M is mantissa and Exp is the exponent.


So you get 6 bytes (not 4 bytes like SGL and also not 8 bytes like DBL)?

Is the mantissa with first 1 omitted (like IEEE754) or does it include the most significant 1? (Does your float numeric allow for un-normalized mantissa?)

Given the unusual byte count:

What does the Sign bit signal? Does TRUE mark a negative number?

What does the Exponent represent? Is it a signed I8 value or an unsigned U8 value? Is there a specific offset or/and any special values?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 8
(1,819 Views)

Hi GerdW,

Yes you get 6bytes and not the 4 and 8 bytes of the SGL and DBL. Yes I the mantissa is omitted and does not include the most significant 1.

The sign bit is for negative or positive number. I think the exponent is an I8. There is no specific offset or special values. 

0 Kudos
Message 3 of 8
(1,811 Views)

So are you converting TO this floating point format? What's the source data?

Edit, nvm, the Unsigned Binary is as you show, and you want an IEEE-754 conforming DBL as output?

0 Kudos
Message 4 of 8
(1,795 Views)

Hi SolPS,

 

it always help when you would link to a manual describing that numeric format…

 

Some bitbanging:

(Tried to follow the usual DBL specifications, but check for errors…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 8
(1,793 Views)

Thanks GerdW. I will try out your example. Much appreciated.

0 Kudos
Message 6 of 8
(1,781 Views)

@GerdW wrote:

Hi SolPS,

 

it always help when you would link to a manual describing that numeric format…

 

Some bitbanging:

(Tried to follow the usual DBL specifications, but check for errors…)


I think that 33 for the mantissa length should be 39 (5 bytes*8bits/byte - 1bit = 39bits)


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 7 of 8
(1,749 Views)

Yes you are correct. I have not tried out it yet but I will let you know when I do. Again thanks for the help..

0 Kudos
Message 8 of 8
(1,742 Views)