LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

format into string 16 bit signed integer

Solved!
Go to solution

Is there any format specifier string for "Format into string", whereas the result is an I16 string?

 

My problem is when I use "%d" and the input string is 65535, the result string should be "-1".

0 Kudos
Message 1 of 9
(4,895 Views)

1!.PNG

Just convert to I16 first then scan to string


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 9
(4,888 Views)

Are you trying to get an integer out of an ASCII string (Scan from String) or turn an integer into a string (Format into String).  You title and question seem to contradict each other.

 

Assuming you are trying to scan from string, it looks like you need to scan into a U16 and then use a conversion bullet to turn it into an I16.


GCentral
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
0 Kudos
Message 3 of 9
(4,887 Views)

The input of the function is a DBL...

0 Kudos
Message 4 of 9
(4,884 Views)

@mitulatbati wrote:

The input of the function is a DBL...


Then use Jeff's code as an example of what to do.  You just have a double input instead of a U32, U16, etc.


GCentral
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
0 Kudos
Message 5 of 9
(4,879 Views)

I did it... the result string is 32767 😞

 

DBL to I16.gif 

0 Kudos
Message 6 of 9
(4,869 Views)
Solution
Accepted by topic author mitulatbati

@crossrulz wrote:

@mitulatbati wrote:

The input of the function is a DBL...


Then use Jeff's code as an example of what to do.  You just have a double input instead of a U32, U16, etc.


Actually you need two conversions
to do that from dbl  (LabVIEW Minutea that might bite you some day:  Float to int retains sign)

1!.PNG


"Should be" isn't "Is" -Jay
Message 7 of 9
(4,865 Views)

Hi mitu,

 

then combine your approach with others shown before:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 9
(4,864 Views)

Hi,

 

there are some other solutions, in each case the result=-1:

DBL to I16.gif

 

 

0 Kudos
Message 9 of 9
(4,817 Views)