LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Converting string to number

Solved!
Go to solution

Here is a screen shot & VI

Download All
0 Kudos
Message 11 of 17
(1,245 Views)

Neither of your attached VI's have the data saved into the string as a default.  They are still empty.  So I'll look at your screen shot that now shows the string.

 

The reason is because the function you are using is intended to look for a single number and treat it as a decimal whole number.  You have a space which means the first number has ended.

 

You need to strip the spaces out of the string before converting.  Then you need Scan from String with %b has the format string.

 

0 Kudos
Message 12 of 17
(1,238 Views)

I want the number to be 1000101011111 not 4447

0 Kudos
Message 13 of 17
(1,230 Views)

Then change the display format of the numeric indicator to binary instead of decimal.

 

You dont actually expect a string of "11111111" as a series of 1's in binary to be converted to the number 11,111,111  (11 million +) in decimal, do you?

0 Kudos
Message 14 of 17
(1,222 Views)

No 

Iexpect a string of "11111111" as a series of 1's in binary to be converted to the number 11111111  in binary but even after search& replace then scan .. the output is wrong

0 Kudos
Message 15 of 17
(1,208 Views)
The output is not at all wrong. Decimal 4447 is equal to binary 1000101011111 which is something basic that you should understand. Whether you display a number in decimal, hex, binary, octal, etc., it's exactly the same number. The display format of a front panel indicator is not going to change the number which is also something basic that you don't seem to understand.
0 Kudos
Message 16 of 17
(1,200 Views)
Solution
Accepted by MarinaNashaat

@MarinaNashaat wrote:

No 

Iexpect a string of "11111111" as a series of 1's in binary to be converted to the number 11111111  in binary but even after search& replace then scan .. the output is wrong


The output is NOT wrong.  Your indicator is set to display decimal.  If you want it to display 1's and 0's, change it to display binary.

 

Does this make it clearer?

 

 

 

I would recommend looking at the online LabVIEW tutorials
LabVIEW Introduction Course - Three Hours
LabVIEW Introduction Course - Six Hours

Message 17 of 17
(1,192 Views)