04-24-2009 08:42 AM
Hi folks.
I am using a "replace array subset" to modify certain values in a binary word or number.
I have coded like in the attached pic.
My doubt is just for better coding and not functionality
Is there a "cleaner" or more effective way to do this, I mean, in terms of array is there another way than just replacing one-by-one.
Hope it's clear enough.
Cheers
04-24-2009 08:53 AM

In general that is correct but code style wise if you use the first index as "14" then the next down is automatically "15".
But your "reverse 1-d Array" make me think that you are reversing for display purposes. If that is the case you may want to use a U16 instead of the array of booleans and format the display for binary. To set the bit you chan then use the bit-wise operations available using an "Or" gate" with a mask of "c0".
I hope some of that is hlepful.
Ben
04-24-2009 09:24 AM - edited 04-24-2009 09:24 AM
04-24-2009 09:27 AM
Try OR with C000 for a 16 bit representation.
Lynn
04-24-2009 09:31 AM - edited 04-24-2009 09:32 AM
04-24-2009 09:31 AM
Sorry Thoric!
As Lynn posted I missed a couple of zeroes. THat is what happens when you do binary to hex conversion in a head that has not been properly initialized with coffee. ![]()
Ben
04-24-2009 09:35 AM - edited 04-24-2009 09:37 AM
In both my snapshots, the block diagram constant (c0 and c000 in the two cases) are both 16bit constants. I take it therefore that the first one is actually 00c0 with hidden leading zeros? Hmmm... ![]()
Any way to set the LabVIEW default representation of Hex displayed values to have no hidden leading zeros? Similarly, the binary displays to show all bits? (I had to set the minimum width of the first control to 16 padded with zeros to prevent it from showing just a single '0').
04-24-2009 09:57 AM
Thoric,
I do not think you can change the default views but you can change the appearance with the properties dialog for both constants and front panel controls and indicators. I am sure that you can set leading zeros on binary displays and I think you can on hex. I do not have LV open now to check.
Lynn
04-24-2009 10:03 AM
johnsold wrote:Thoric,
I do not think you can change the default views but you can change the appearance with the properties dialog for both constants and front panel controls and indicators. I am sure that you can set leading zeros on binary displays and I think you can on hex. I do not have LV open now to check.
Lynn
Yes, that's precisely how I changed my front panel controls to show all 16 bits in binary display mode. It would just be nice for this "pad with leading zeros" to be the default when you convert a display from Floating Point to either Binary or Hex. That's how my calculator shows values afterall when in Binary or Hex mode.
04-24-2009 10:06 AM
You could submit that as a product suggestion. NI does listen to suggestions, particularly when a good case can be made that the change will be a significant help for customers and if it will not break existing code.
Lynn