LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Bitwise shift operation?

Solved!
Go to solution

int16 x = 0x0;

int16 y = 0x0;

 

for (int8 i = 0; i < 16; i++)

{

    result1 = 0x1 << i;

    result2 = 0xff00 >> 8;

}

 

Any idea?

 

Thank you in advance.

 

 

0 Kudos
Message 1 of 6
(18,596 Views)

Numeric Palette >> Data Manipulation  >>>> Logical Shift.

 

Or search the palette for "shift".

Message Edited by Ravens Fan on 07-15-2009 05:23 PM
0 Kudos
Message 2 of 6
(18,595 Views)

Thanks for the quick info, but I am not sure I understood the details on logical shift correctly.

According to description, it says "If y is less than 0, the function shifts x right y bits" and

this conflicts with my example, so how do you shift right if Y value is not less than 0?

Could you show me the labview example for my case?

 

Thank you in advance.

0 Kudos
Message 3 of 6
(18,589 Views)
Solution
Accepted by topic author horanyee

horanyee wrote:

... so how do you shift right if Y value is not less than 0?


multiply y by -1 first. There is a primitive in the numeric palette called negate.

0 Kudos
Message 4 of 6
(18,583 Views)

Read the whole description.

 

"If y is greater than 0, the function shifts x left y bits (from least significant to most significant bit) and inserts zeros in the low-order bits. If y is less than 0, the function shifts x right y bits in the positive direction (from most significant to least significant bit) and inserts zeros in the high-order bits. "

 

If Y is positive, the shift is to the left y bits.  If Y is negative, the shift is to the right y bits.

Message Edited by Ravens Fan on 07-15-2009 05:44 PM
Message 5 of 6
(18,574 Views)

I was think too hardSmiley Very Happy

 

Thank you.

0 Kudos
Message 6 of 6
(18,569 Views)