LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

mask bits in an integer value

Ok, I am new to Labview, but I have a lot of experience with C and CVI.

So, how do I take an integer value and mask off the lower 8 bits?
In C I just use   i16_value &= 0x00FF;

How do you do this in Labview? I've tried formulas.

And please include a working example. This is a real paradyme shift for me.

Thanks,

0 Kudos
Message 1 of 7
(4,346 Views)
Use the logical AND (Boolean palette!) with a diagram constant of 0x00FF (Format the constant as HEX for convenience).
 
What is your LabVIEW version?

Message Edited by altenbach on 07-18-2005 01:31 PM

0 Kudos
Message 2 of 7
(4,343 Views)
I do not have LV available right now, but in the past I recall that you could wire integers to the basic logic functions, such as AND. Many LV functions have polymorphic inputs, meaning that they can adapt to various types of data. Most math functions will accept integer, real, and, in some cases, complex data types. Case structure selectors will accept Boolean, integer, or string types.

Lynn
0 Kudos
Message 3 of 7
(4,331 Views)

Actually, I was thinking that the syntax you gave should work in a formula node. I know there is a way of doing it like that--check the help for the formula node.

In any case one thing in altenbach example that deserves highlighting is the formatting of the constant. To improve the readability of your code be sure to reformat the display of constants to present their contents in hex or binary (depending upon your application). This will help folks understand what you were doing.

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 4 of 7
(4,315 Views)
Thanks,

I think I am shifting now. I never really got into C++, so there was no thought about sending an integer into a Boolean and expecting it to know what to do with it.

I also found a 'Compound Arithmetic' function in the numeric pallet. I think that the suggestion to use the AND function will be more readable.

Jim

0 Kudos
Message 5 of 7
(4,304 Views)

P.S.  It is paradigm, not paradyme.
0 Kudos
Message 6 of 7
(4,302 Views)
As you are shuffeling your four nickles around (pair o' dimes?), the compund arithemtic function is great because it lets you exactly model your logic. For example, say you are needing a gate that produces an output value of true if either input is false. The normal way of implementing that would be with a NAND gate. The problem is that all though the actual function works-out being what you want, the NAND logic doesn't represent the way you are thinking about the problem.
 
The complex arithemtic node on the other hand, allows you to create an OR gate with inverters on both inputs, thus exactly representing what you are trying to do functionally and logically.
 
Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

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

For help with grief and grieving.
Message 7 of 7
(4,297 Views)