ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

取消
显示结果 
搜索替代 
您的意思是: 

Binary string to binary number conversion

已解决!
转到解答

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 项奖励
1 条消息(共 18 条)
7,325 次查看

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

snippet.png

2 条消息(共 18 条)
7,292 次查看

You can try something like this:

Capture.PNG

3 条消息(共 18 条)
7,282 次查看

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.

4 条消息(共 18 条)
7,224 次查看

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.眨眼表情

content.PNG

0 项奖励
5 条消息(共 18 条)
7,212 次查看

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

6 条消息(共 18 条)
7,172 次查看

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 项奖励
7 条消息(共 18 条)
7,145 次查看
解答
接受人 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).

8 条消息(共 18 条)
7,136 次查看

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 项奖励
9 条消息(共 18 条)
7,118 次查看

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 项奖励
10 条消息(共 18 条)
7,105 次查看