LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

(# of bits ) in a number

Solved!
Go to solution

I am converting from decimal to binary and I am trying to get the number of bits in this binary number which is called  "Resulting Binary Numer" output in the VI ... How can I get it ?

0 Kudos
Message 1 of 4
(3,132 Views)

LabVIEW and all computers converts the decimal number that you enter to binary.

LabVIEW can ONLY work in binary.

 

So all you need to do is to tell LabVIEW not the display the binary number as human readable decimal

but to keep it in binary and display it in binary.

Omar
0 Kudos
Message 2 of 4
(3,121 Views)
Solution
Accepted by topic author MarinaNashaat

The #Bits control SETS the minimum number of characters in the string.  The string will contain as many more characters as required to represent the number.

 

It sounds as though you are trying to determine the length of the minimum string which will display a binary representation of your number.

 

If you use a %b format string and check the length of the output string it will tell you the number of characters in the binary string.  You can also format the numeric control or indicator to display in binary, provided the representation is one of the integer data types.

 

With your decimal input set to I32 you need to be careful with negative numbers. They all have the same length = 32.

 

Lynn

Message 3 of 4
(3,104 Views)

I have no idea why you are scanning the result as a fractional number, there should be no orange anywhere.

 

Your question really does not make a lot of sense, but listen to Lynn for some ideas. 😉

 

In any case, please take a step back and explain where and why you need this. What will it be used for? Do you need the string or the numeric datatype at the end? Who will read it later (a human? a subVI? another program?)

 

 

0 Kudos
Message 4 of 4
(3,087 Views)