09-08-2011 11:28 AM
Hi everyone.
I am new to Labview, so I apologise if this question is too simple. I am trying to convert a float to a hex string so I can pass it to a VISA Write VI. I first cast it, so it becomes a 32-bit int and then on to the 'number to hex string' VI. Now, since after the casting the number is a 32-bit int, I would assume that the output hex string would also be 32-bit long (so 4 bytes, which is what I need). However, I use the 'string length' Vi and it says the hex string is 8-byte long. Could someone please tell me why this is the case?
Thank you very much in advance,
Gabriel
09-08-2011 11:49 AM - edited 09-08-2011 11:51 AM
Are you sure it is 8 bytes? Don't confuse a nibble and a byte.
Try the "flatten to string" function.
09-08-2011 12:10 PM
The number to hex string VI converts a number to an ASCII string representation of the number, so 0xABCDEF01 would become the literal string "ABCDEF01", which is 8 bytes long. If you want the int converted into the binary string, you can use type cast to cast it to a string. Then it would be a the string "\AB\CD\EF\01" which would be 4 bytes, the first character ASCII 0xAB, etc.
09-09-2011 04:53 AM
Thanks a lot, type cast solved it. I didn't know it could output strings too.