12-11-2009 10:26 AM - edited 12-11-2009 10:36 AM
I am trying to scan an unsigned 32 bit integer value from a string. I have tried changing the format string from %d to %u with no luck. The function keeps returning 0x7FFFFFFF (2147483647) when the hi bit is set.
Can the format string be defined such that LabView will read an unsigned 32 bit integer value?
Thanks for your help,
Phil
Solved! Go to Solution.
12-11-2009 10:38 AM - edited 12-11-2009 10:43 AM
Hi Phil,
have you opened the context help and read the help for format codes? Then you would have picked %x instead of %u
And you would have read too about the default data input of the ScanFromString function...
And why do you use that local variable when you have an unwired indicator for free???
And you can connect the error cluster directly to the while loop stop terminal...
12-11-2009 10:45 AM
Gerd,
Thanks for your reply. Doesn't %X scan hexadecimal values? My values are actually decimal formatted. I'm scanning from a file and the values look like:
3343385820,
3343385850,
3343385879,
Phil
12-11-2009 10:49 AM
No, use %d. If you read these numbers as %x, they will overflow. In addition, you need to wire a U32 diagram constant to the "default value" input of "scan from string", else you get I32, which is inusfficient for your data.
12-11-2009 10:53 AM
12-11-2009 11:00 AM - edited 12-11-2009 11:01 AM
Added notes:
Overall, your code is overly complicated.
12-11-2009 11:04 AM
12-11-2009 11:09 AM - edited 12-11-2009 11:10 AM
Dennis Knutson wrote:
If you connect a U32 indicator directly to the output of the scan from string, the output of it also changes to a U32 and the conversion is correct.
Unfortunately, it does not propagate back across tunnels as in the code at hand, thus we need to wire the a diagram constant of the correct datatype (e.g. U32) to the default value input anyway.
Still, as I said earlier, there are better ways to do all that... 😉