11-20-2008 12:36 PM
11-20-2008 07:45 PM
Jason,
You can try this:
Locals.OutputValue = (Locals.One << 16) | Locals.Two
I did this with the following values and let TestStand do the conversion, since all values in TestStand are stored as doubles regardless of viewing format:
My watch expressions showed the following:
Locals.OutputValue = 2271560481.000000 // formatted as Real
Locals.One << 16 = 0x87650000 // formatted as "0x#.8X"
Locals.Two = 0x00004321 // formatted as "0x#.8X"
Locals.OutputValue = 0x87654321 // formatted as "0x#.8X"
(Locals.One << 16) | Locals.Two = 0x87654321 // formatted as "0x#.8X"
I think you are on the right track, and TestStand will convert what you want.
-Jack
11-21-2008 01:30 AM - edited 11-21-2008 01:32 AM
11-21-2008 08:07 AM
11-21-2008 09:39 AM - edited 11-21-2008 09:48 AM
Hi,
that means your hole dword is repesenting a 32bit float ?
addtional http://de.wikipedia.org/wiki/IEEE_754
in C/C++
i would call this function;
float toFloat(WORD wLow, WORD nHigh)
{ union{WORD[2] warray;
float fVal;} myUnion;
myUnion.warray[0] = wLow;
myUnion.warray[0] = nHigh;
return myUnion.fVal;}
juergen
11-21-2008 09:50 AM
I see, you don't want to treat the 16bit integers as integers, you want to reinterpret them as the binary bits of a 32-bit floating point number. Not sure if there is a way to do this in a LabVIEW VI (perhaps someone who knows LabVIEW better than me can help if needed), but you can do this in a C/C++ DLL as follows:
float ConvertBitsToFloat( unsigned short highbits, unsigned short lowbits)
{
float retval;
DWORD * floatbits = (DWORD *) &retval;
*floatbits = ((DWORD) highbits << 16) | (DWORD)lowbits;
return retval;
}
Hope this helps,
-Doug
11-21-2008 10:03 AM
11-21-2008 01:17 PM
You cannot do a reinterpret cast in the TestStand expression language. You could parse the exponent and the mantissa out of the 32-bits and use floating point arithmetic and functions to recreate an equivalent value, but it would be tricky, especially if you want to support corner cases like INF, IND, and NAN.
If you think you know how to do the conversion in LabVIEW already, I'd recommend just writing a utility VI in labview which does this and call that from TestStand. There's no need to modify existing VI, you just need to write a new one to do the conversion.
Hope this helps,
-Doug