LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Binary string to binary number conversion

Solved!
Go to solution

Hello guys, sorry to bother you and thanks for watching over here.

 

I am currently doing the conversion from string to a binary number(I have string like1001000110 which is binary, what I'd like to do is passing the exact same value of the binary number from the string)

What I am getting the value from the 'Fract/Exp string to number' function now is '1E+10', is there any way to pass the exact same value in the string rather than 1E+10?

shot.PNG

0 Kudos
Message 1 of 18
(4,116 Views)

Instead of "Fract/Exp string to number", you should use "Scan From String" with %b to signify binary input:

snippet.png

Message 2 of 18
(4,083 Views)

You can try something like this:

Capture.PNG

Message 3 of 18
(4,073 Views)

Of course, IIRC, both don't adapt to arrays (sadly). You'd need a for loop around them.

 

If the entire file is binary, you can try this:

Spreadsheetstring to binary.PNG

Easier and more flexible, IMHO.

Message 4 of 18
(4,015 Views)

Thanks for your replies!

 

As you can see, what I am using now is 'index array' to separate values in two columns, and the purpose for this is to make a lookup table, so after the 'filter' which is index array, it will give two 1D arrays from that, while 'scan from string' can not accept 1D array of string.

Here is the content in the txt file, so maybe you can have a look.Smiley Wink

content.PNG

0 Kudos
Message 5 of 18
(4,003 Views)

Thanks for the data, it is easier to help with that.
I guess combining Gregory's or prettypwnie's suggestion with wiebe@CARYA's remark about for loop would be the solution.

Capture.PNG

Message 6 of 18
(3,963 Views)

Hi RolfO,

Thanks for your reply!

But it is strange that I pass the value after the 'scan value' function, the binary string turns to decimal somehow... Is there anything that I need to be aware?scan value.PNG

In the graph, value is coming out of the scan value and String 2 is the binary string.

0 Kudos
Message 7 of 18
(3,936 Views)
Solution
Accepted by topic author AlEXINUK

@AlEXINUK wrote:

Hi RolfO,

Thanks for your reply!

But it is strange that I pass the value after the 'scan value' function, the binary string turns to decimal somehow... Is there anything that I need to be aware?scan value.PNG

In the graph, value is coming out of the scan value and String 2 is the binary string.


Not sure what's happening, but I can guess.

 

You convert the string to a number, using Scan From String or Scan Value. The result is a number. This number will show decimally, by default. If you want it to display it's value binary, you have to format it binary (right click the indicator, Display Format).

Message 8 of 18
(3,927 Views)

The binary number 00000011100 is exactly the same as decimal number 28. Its only the presentation which differs because the number base is different. The same number in hex base is 1C

 

If you as an example use the function "Format into string" with format "%d" you will get a decimal number without decimals. 

"%f" gives the number in decimal representation with decimals. "%x", "%o" and "%b" gives a string with hex, octal and binary representation.

And as wiebe@CARYA said, you have the possibility to change how a number is presented in numeric indicators and controls. There also is a possibility to make the radix visible. This will indicate which radix/base the indicator/control uses for presenting the number.

0 Kudos
Message 9 of 18
(3,909 Views)

Thanks for your advice and it works!

But binary string turns from 00000011100 to 11100, is there any solutions for this?

And also, in@rolfO's reply,  turns the indicator after the scan value to array type, could you please tell me how to change that as well? The default type is not array and I can't find this in display format.

 

Thanks for your patience!

0 Kudos
Message 10 of 18
(3,896 Views)