LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Binary String to Decimal

Very basic question. If I have a binary string 0011 how do I convert it to its decimal form of 3. I presume the Format into string block could do this but what constant do I wire into it. %d is it?
Thanks
kilyg
0 Kudos
Message 1 of 5
(3,405 Views)
Hello kilyg:

You can convert it first to a binary number using "%b" constant, then convert it to a decimal string using "%d".

Please inform me if you have further questions.
0 Kudos
Message 2 of 5
(3,385 Views)
You actually want the "Scan From String" function, (it's right next to the "Format Into String") with a %b on the format string. This will give you a numeric I32.

If you want this as a string, then use the "Format into String" with the %d format string.



Ed

Message Edited by Ed Dickens on 03-04-2005 10:25 AM



Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
0 Kudos
Message 3 of 5
(3,385 Views)
Basic questions can be confusing: Do you want '3' as a numeric or do you want it as a string '3'.

Assuming you want the result numeric:
1) If your "binary string 0011" is 4 bytes (i.e. ascii): use Scan from String with %b (%d reads decimal characters).
0r
2)If your "binary string 0011" is a 4 bit nibble: typecast.
=====================================================
Fading out. " ... J. Arthur Rank on gong."
0 Kudos
Message 4 of 5
(3,387 Views)
hi ,

if ur input is not a string and u want ur result as a numeric u can try this

1. take a numeric control,select the "representation" option, in that select 8 bits .
2 .then at the output create an indicator change the representation of this indicator to "DBL"
3 there u will obtain the decimal equivalent of the binary input.

check out the sample vi.

tanisha
0 Kudos
Message 5 of 5
(3,360 Views)