ni.com is currently undergoing scheduled maintenance.

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

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

zero fill string

Solved!
Go to solution

I am converting a decimal string into the binary equivalent using the format into string function, just wondering if there is a way to left zero fill the results?  For example I have  5 converted to 1001 but would like to have the output string as 00001001, thanks.

0 Kudos
Message 1 of 7
(3,704 Views)

After the part you have accomplished (5 -> 1001), measure the length of the converted string and concatenate the desired number of zero characters at the beginning of the string.

 

Lynn

0 Kudos
Message 2 of 7
(3,698 Views)
Solution
Accepted by topic author svt4cobra6

format string

 

%08b

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 3 of 7
(3,693 Views)

thanks for the replies, changing the format specifier worked.

0 Kudos
Message 4 of 7
(3,688 Views)

You wil use format into string function with format string "%08b". The zero tells to pad with zeros on left. The eight tells the number of digits and b convert to binay.

0 Kudos
Message 5 of 7
(3,687 Views)

@svt4cobra6 wrote:

thanks for the replies, changing the format specifier worked.


Good.

 

BTW

 

5 ===> 101

9 ===> 1001

 

now Ifeel better. Smiley Wink

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 6 of 7
(3,683 Views)

yep thanks for the correction on the binary math!  

0 Kudos
Message 7 of 7
(3,669 Views)