LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Access individual bits of a long data type

Hi,

I'm using a DLL with LabVIEW at the moment and one of its properties
is to return the version of the DLL as a long integer. The bitfields
are as follows:

[31-24] Major version.
[23-16] Minor version.
[15-00] Build number.

How can I split the long up into the relevant bits so that I can
display the version number correctly?

Regards,

Adrian.
0 Kudos
Message 1 of 4
(2,735 Views)
There is a function on the numeric function palette that turns an integer into a boolean array. You could then index out the bits you want for each portion of the word and turn the array consisting of those bits back into a number. (see attachment)

Note that you could also do it by manipulating the input number directly through logic functions that mask off the unwanted bits for each value and shifting the result. But the readability would suck.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 4
(2,735 Views)
Hi Adrian,

in your case it is easier to use the "SplitNumbers" from the Advanced/Data Manipulation palette. (see attached example). In a more general way: use an
AND with a mask value and shift the result to the
right accordingly...

Best regards,
Gerd Wieczorek
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 4
(2,735 Views)
Adrian Gibbons wrote:
> Hi,
>
> I'm using a DLL with LabVIEW at the moment and one of its properties
> is to return the version of the DLL as a long integer. The bitfields
> are as follows:
>
> [31-24] Major version.
> [23-16] Minor version.
> [15-00] Build number.
>
> How can I split the long up into the relevant bits so that I can
> display the version number correctly?
>

Your bitfields make things easy by being aligned on byte boundaries.

Have a look on the Advanced palette under data Manipulation, you
should find a 'split Number' vi, which will split a 32 bit number
into 2 16-bit numbers and can then be used to split one of these
further into 2 8-bit numbers.

That should do it.

If you want to split arbitray bits out of a number, have a look at
the 'Num
ber to Boolean Array' Vi on the boolean palette.



--
Remove "spamkill." when replying to this message
0 Kudos
Message 4 of 4
(2,735 Views)