LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert decimal number to binary number

Thank you so much! 

0 Kudos
Message 11 of 21
(184 Views)

"Simplify" is a loaded word and can mean many thing to different people. 😄

 

A cluster is not very scalable and requires a lot of work (change output size for array to cluster, create all the cluster elements and customize their colors, size, and boolean text, etc. The cluster should even be made into a strict typedef to avoid mixups).

 

A cluster is more cosmetic than functional and it really depends what you want to do with the bits downstream. Maybe just leave it as U8 scalar or boolean array.

 

(Note that reversing the array as I did is not needed, of course. It was just to easily compare the binary formatted number (where the LSB is on the right) with the array, which has the LSB on the left.

 

One possible alternative for display would be a listbox. Now it would be much easier to e.g. change the language.

 

altenbach_0-1750169347635.png

 

 

On a curious side note (not recommended for new users):

You can use 4.x mode typecast to convert the string directly into a boolean array, but be aware that the MSB is now element zero.

 

altenbach_1-1750169825786.png

 

 

 

 

Message 12 of 21
(169 Views)

I find that changing it to a cluster with explicitly named Booleans to be more convenient for me and very nearly as easy to manipulate.  True, it's not scalable, but all the times I've ever used clusters of Booleans, they were already defined in a document, was usually part of a message, and if the message changed, that meant a lot more than just redefining a cluster of Booleans.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 13 of 21
(165 Views)

@billko wrote:

I find that changing it to a cluster with explicitly named Booleans to be more convenient for me and very nearly as easy to manipulate.  


There's nothing wrong with a cluster if the meaning of the bits is well defined and fixed and downstream code is equipped to handle it.

 

Any specific bit can be queried using unbundle by name. Other queries are a bit more difficult with a cluster (Are all TRUE? Are all FALSE? How many are true? Which ones are true?, etc.) 😄

0 Kudos
Message 14 of 21
(142 Views)

@altenbach wrote:

"Simplify" is a loaded word and can mean many thing to different people. 😄

 

A cluster is not very scalable and requires a lot of work (change output size for array to cluster, create all the cluster elements and customize their colors, size, and boolean text, etc. The cluster should even be made into a strict typedef to avoid mixups).

 

...


OK.  How's this:

paul_a_cardinale_0-1750197657374.png

 

Message 15 of 21
(135 Views)

@altenbach wrote:

@billko wrote:

I find that changing it to a cluster with explicitly named Booleans to be more convenient for me and very nearly as easy to manipulate.  


There's nothing wrong with a cluster if the meaning of the bits is well defined and fixed and downstream code is equipped to handle it.

 

Any specific bit can be queried using unbundle by name. Other queries are a bit more difficult with a cluster (Are all TRUE? Are all FALSE? How many are true? Which ones are true?, etc.) 😄


Well, yes, you need to change it into an array using this guy: billko_0-1750199477806.png

 

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 16 of 21
(127 Views)

@billko wrote:
Well, yes, you need to change it into an array using this guy: billko_0-1750199477806.png

 


Never heard of it 😮 JK

 

(of course we already had that same array earlier upstream... :D)

0 Kudos
Message 17 of 21
(118 Views)

@paul_a_cardinale wrote:
OK.  How's this:

paul_a_cardinale_0-1750197657374.png

 


Its probably insignificant here, but I historically have an aversion for overlapping front panel elements and typically avoid them at all costs. Back in the days, lots of overlapping controls were over-taxing the UI thread.

 

The exact same code could use a cluster of a checkbox and a string next to each other, but we are losing the color. 😮

 

altenbach_0-1750253811715.png

 

This thread has somehow derailed from "how do I get the bits" to "how do I show the bits" and there are millions of ways to do that. Some are easier on the eye, and some are easier for downstream code. There is no real right or wrong until we see the full requirements document. 😄

We might even do a mockup of several alternatives shown here and let the customer decide.

 

Personally, I probably would just keep it as U8 internally and create a subVI that formats the entire information into a multiline string using Consolas font (i.e. fixed width) whenever the user needs to see it. 😮 

0 Kudos
Message 18 of 21
(98 Views)

@altenbach wrote:

@paul_a_cardinale wrote:
OK.  How's this:

paul_a_cardinale_0-1750197657374.png

 


Its probably insignificant here, but I historically have an aversion for overlapping front panel elements and typically avoid them at all costs. Back in the days, lots of overlapping controls were over-taxing the UI thread.

 

The exact same code could use a cluster of a checkbox and a string next to each other, but we are losing the color. 😮

 

altenbach_0-1750253811715.png

 

This thread has somehow derailed from "how do I get the bits" to "how do I show the bits" and there are millions of ways to do that. Some are easier on the eye, and some are easier for downstream code. There is no real right or wrong until we see the full requirements document. 😄

We might even do a mockup of several alternatives shown here and let the customer decide.

 

Personally, I probably would just keep it as U8 internally and create a subVI that formats the entire information into a multiline string using Consolas font (i.e. fixed width) whenever the user needs to see it. 😮 


Even if the user needs to see it, if you don't need labels on your Booleans, you could just display the U8 in binary.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 19 of 21
(87 Views)

@billko wrote:
Even if the user needs to see it, if you don't need labels on your Booleans, you could just display the U8 in binary.

... forcing the user to find the manual and look up the meaning. 😄

 

Of course it could be put in the legend or some free text. Here's how the legend could look like 😮

 

altenbach_0-1750268480961.png

 

0 Kudos
Message 20 of 21
(79 Views)