03-01-2013 10:41 AM
I need to brush up on my text base skills. I am reading somebody elses code and it contains this formula node. Any help understanding the logic inside or seeing a LabVIEW equivelent would be much appreciated.
Solved! Go to Solution.
03-01-2013 12:32 PM
Can you attach the actual formula node in a new VI. I doubt that we currently see the full code.
03-01-2013 12:32 PM - edited 03-01-2013 12:57 PM
Very odd snippet of code.
All but the first line should be self explanitory. Everything on the first line though are bitwise operators.
Basically it is stating that if the Nth bit of variable A is a 1 (N being j-i) then set X=2
For example: A = 11, j=6, i=3, f=8
A (in binary) is 1011. So A right shifted 3 places (6-3) = 1 so 1 & 0x01 = 1 -- so set X = 2
Edit: fixed a typo
03-01-2013 01:06 PM
Here is the whole node. Thanks
03-01-2013 01:09 PM
Hey Don, can you explain the &0x01 portion?
Thanks
03-01-2013 01:11 PM
That is masking out all the other bits and only looking at the 0th (1's) bit so you can get a simple 0 or 1, rather than other numbers in the event other bits are set within the number that you don't care about.
03-01-2013 01:23 PM
@Pat_H wrote:
Here is the whole node. Thanks
Ah, thanks. Now we see the curly brace at the end. 😄
03-01-2013 01:29 PM
Pat_H wrote:
What is up with the 'f' outside the box?
03-01-2013 01:31 PM - edited 03-01-2013 01:31 PM
How about some nice G code to look at.
03-01-2013 04:22 PM
Thank you all!