LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
0 Kudos
Andi_S

string to number shall take care for representation

Status: Declined

Any idea that has not received any kudos within a year after posting will be automatically declined. 

I don't know if this is a bug or a feature ... but please see the pictures to understand what I mean:

 

HexString.jpg

 

Because I use the representation U8 I would expect a value of 0x3F and an offset of 2.

It seems that LV first converts the string to a number and then it converts it to the given representation. I think the reverse processing order would be much better.

Maybe there could be an option added (boolean input or context menue).

 

 

 

4 Comments
AristosQueue (NI)
NI Employee (retired)

The existing behavior is deliberate and will not be changed. If you need more discrete parsing, separate the string into separate units and then call the primitive.

The reason for the existing behavior is that some numeric types do not have a clearly distinguishable boundary for length (i.e. floating point) and others have characters (negative sign) that would make it ambiguous about whether they can be parsed or not. So the parsing behavior is fixed for "numeric" and then the representation is taken into account after.

 

crossrulz
Knight of NI

You could use Scan From String with %02x as the format string.  Then it would only parse the first two characters into your U8.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
X.
Trusted Enthusiast
Trusted Enthusiast

According to the Help:

 

"If the input string represents a number outside the range of the representation of number, number is set to the maximum value for that data type".

 

Number is the output (Value in your snapshot).

Darren
Proven Zealot
Status changed to: Declined

Any idea that has not received any kudos within a year after posting will be automatically declined.