LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Ieee754

I have an output from a MAss Flow Controller in IEEE 754 floating point its 42 48 00 and it is supposed to be 50. How does one convert that into 50
0 Kudos
Message 1 of 5
(4,689 Views)

Your instrument sends back measures in little-endian format, that is with the most significant byte first. BTW, the number is a 4-byte one: an additional 00 byte must be at the end the string. You can reverse bytes order and simply cast the string into a float, this way ("tmp" is the variable into which you read back from the instrument):

static char tmp[4];
tmp[0] = 0x0;
tmp[1] = 0x0;
tmp[2] = 0x48;
tmp[3] = 0x42;

DebugPrintf ("%f\n", *(float *)tmp);

For a small reference on IEEE754 format, you can look at this page: it's useful to validate conversion algorithms you develop to translate instrument raw data.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 5
(4,683 Views)
That does work but I am trying to concatenate strings and I cannot concatenate that output string with a hex display with the rest beacause the othersa are on normal display
0 Kudos
Message 3 of 5
(4,667 Views)
I didn't understand your comment about concatenating: I used DebugPrintf to obtain an immediate printed result of the conversion, but you can substitute it with sprintf to format your variable into the message you need.
 
Or simply I didn't catch your problem: can you explain it better?


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 5
(4,662 Views)
I found a solution thank you very much for your help
0 Kudos
Message 5 of 5
(4,646 Views)