The Daily CLAD

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

Re: DBL to Case Structure Selector

SercoSteveB
Active Participant

What are the contents of Numeric Array Out following execution of the VI?

 

Case Structure Doubles.png

NOTE: The content of the other cases within the Case Structure are shown below:

Case Structure Doubles - Other Cases.png

 

Case Structure Doubles - Answers.png

Comments
Tsjabrantes
Member

The first index of the array (0,49) will call default case which contains (-99), resulting  0 in output;

The second index array (0,5) will call case 1 wired direct to output, resulting 0 in output...

The third index array (0,51) will call case 2 wired direct to output which system rounds up to 1;

So the correct answer is B.

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
crossrulz
Knight of NI

Tsjabrantes, your logic is completely out of whack.  How would calling the default case, which has -99 wired to the output tunnel, result in a 0?

 

The case structure does not work on floating point numbers.  It coerces to an integer.  Therefore, things get rounded.  0.49 rounds to 0, so case "0" is called.  0.51 rounds to 1, so case "1" is called.  0.5 rounds to the nearest even number (look up Banker's Rounding, which is the IEEE standard) which means it calls case "0".


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

Sorry 

 

 

 

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

it should be B)

 

floats <= x.5 will be rounded towards negative infinity

floats  >  x.5 will be rounded towards (positive) infinity

 

which means 0.49 -> 0; 0.5 -> 0; 0.51 -> 1


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
crossrulz
Knight of NI

jwscs,

Please reread my last comment.  When it comes to default rounding (ie when you coerce a float into in integer), Bankers Rounding is used, which means you round to the nearest EVEN number when at X.5.  This has been discussed many times on this board along.


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
sdonaldson
Member

B

MrStevenUND
Member

 B

CataM
NI Employee (retired)

b)

LV_COder
Member

B

qubirt
Member

B

Matt-A.
Member

B

SercoSteveB
Active Participant

Answer: B.  Nice one all.

 

 

decarr
Member

Banker's Rounding is a new term for me - I learn something every time I check this blog!!