The Daily CLAD

Community Browser
cancel
Showing results for 
Search instead for 
Did you mean: 

Re: CLAD2017 - Data Manipulation - We are really shifting now

SercoSteveB
Active Participant

Consider the VI, what is Numeric Value Out?

 

Shifting.png

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)

Comments
nishith04
Member

b)

Tsjabrantes
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.

Smiley Happy

Tarciso Junior
+55 (11) 996-282-103
Skype: Tarciso.junior2
Email: Tsjabrantes@gmail.com
http://br.linkedin.com/pub/tarciso-junior/23/a83/463
nik35324
Member

B

crossrulz
Knight of NI

B


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
GladysToMeetYou
Member

B

monesh
Member

b)

Ellie90
Member

b

CataM
NI Employee (retired)

b)

Matt-A.
Member

B

qubirt
Member

B

A_rid
Member

Anyone can explain how it works please? Thanks in advance

SercoSteveB
Active Participant

Hi A_rid, check this out.

A_rid
Member

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

crossrulz
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).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
A_rid
Member

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

SercoSteveB
Active Participant

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

MAX_2019
Member

B

SercoSteveB
Active Participant

Answer: B.  Nice one all.

 

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.

Oleksiy7979
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?

crossrulz
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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Oleksiy7979
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.

istan0227
Member

B