LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert double to IEEE 754(hex???) array

Solved!
Go to solution

Hi,

 

is there built-in function of Labwindows to convert double into array of IEEE 754 (or hex???, i am not so sure)

Like this:

Double                    Hex array

40                          00 00 42 20

40.5                        00 00 42 22

40.8                        33 33 42 23

 

Thank,

 

(PS: the hex arraies above are calc by Type-Casting in Labview)

0 Kudos
Message 1 of 4
(4,667 Views)

Sorry guys

i made a mistake between IEEE 754, hex, float, double

Here is the question:

 

I have a float-value (IEEE754) in labwindows, How can i convert it into unsigned int?

Would it be easier, if i use double instead of float?

0 Kudos
Message 2 of 4
(4,662 Views)
Solution
Accepted by topic author Chocobombo

As far as I can tell, there is no built in function in LabWindows to do that, so you'll have to use what's available in C.  The two ways I know of is to use pointers to cast the pointer to the float value as a pointer to an unsigned int type and then retrieve the value as such:

 

	float f = 40.0f;
	unsigned int u;
	
	u = *((unsigned int *)&f);

 The other way is to use unions, which may be more convienent if you have to do this a lot.

union ex32
{
	float fval;
	unsigned int uval;
};

	float f = 40.0f;
	unsigned int u;
	union ex32 t;
	
	t.fval = f;
	u = t.uval;

 

 

 

 

Message 3 of 4
(4,653 Views)

Thank tstanley, u saved my day 😄

0 Kudos
Message 4 of 4
(4,627 Views)