cancel
Showing results for
Did you mean:

CLAD2017 - Data Manipulation - We are really shifting now

Active Participant

Consider the VI, what is Numeric Value Out?

a) Numeric Value Out = ((A+B)-C) << (A+B)

b) Numeric Value Out = (A+B) << ((A+B)-C)

c) Numeric Value Out = ((A+B)-C) >> (A+B)

d) Numeric Value Out = (A+B) >> ((A+B)-C)

Member

b)

Member

Hello everyone!

For this exercise the output result is option B.

The logical shift operation shifts all bits including the sign bit of a signed integer.

Tarciso Junior
+55 (11) 996-282-103
Skype: Tarciso.junior2
Email: Tsjabrantes@gmail.com
Member

B

Knight of NI

B

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Member

B

Member

b)

Member

b

NI Employee

b)

Member

B

Member

B

Member

Active Participant

Hi A_rid, check this out.

Member

SercoSteveB thank you! But in the event that (A+B)-C is less than zero, the result would it be simbolically the same??

Knight of NI

The same as what?  If (A+B)-C is negative, then we just shift in the other direction.  So it would turn into (A+B) >> C-(A+B).

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Member

Ok now it's clear! Thank you and SercoSteveB!

Active Participant

Yep, symbolically the same, but as crossrulz points out we would shift in the other direction.

Member

B

Active Participant

The input terminals for this one seem around the wrong way to me, I expect it to be Top Terminal Value << Bottom Terminal Value.  I have to remember to reverse what I think when I use this one.  Ho hum just another thing to remember.

LabVIEW 2017 Help for the Logical Shift function.

Member

LabVIEW 2017 Help for the Logical Shift function does not explain anything to me.  It says:

the function shifts x left y bits (from least significant to most significant bit) and inserts zeros in the low-order bits

But what it really means I have no clue. Too bad that I have no Labview during the preparation, so I can only guess what will be the x << y result. Can anyone explain what happens with the bits in a real life example?

Knight of NI

I will just assume you know what a bit is and that numbers are nothing but a collection of bits.  So what we are doing here is moving the bits in a number.  So let's just say I have an U8 with a value of 10.  We can represent that value in hex (0x0A) or in binary (0b00001010).  The binary view shows the bits nicely.  So now lets shift the bits by 1.  10 << 1 = 20 (0x14, 0b00010100).  Just for fun, let's do a shift of -1. 10 << -1 = 10 >> 1 = 5 (0x05, 0b00000101).

If you still don't understand this, then I highly recommend taking some digital electronics courses.

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Member

Thank you crossrulz for explanation. I understand now. It is just takes a lot of time for me to understand that 10100 is 20 in binarese language.