From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

CLAD Preparation guide questions

Solved!
Go to solution

So I had a couple questions about the practice questions in the CLAD prep guide. The first is question 3 on page 15 (pictured below). My problem with this is its label is "Switch When Released", and the picture next to it is of a "Latch when released" control. But it never really explicitly says what the control is. I can't tell if its meant to be deceiving, or just a poorly made question. The answer is C making it a "switch when released" control, I guess I just want opinions on if you think its supposed to be tricky, or if its just a poor question. 

 

q3.PNG

 

My other question is on question 7 on page 24, below. I recreated this vi on my own because I wasn't sure if the coercion would round the double, or if it would do like casting in c and just remove after the decimal. What I found was interesting, when you coerce 2.5, it is 2. But when you coerce 1.5, its 2. and 3.5 is 4. I did this both with the case statement and with the double to I16 function. What is happening here in the math? Is it rounding or doing some other weird thing?

 

I just tried one other thing that made the picture a little clearer, but it still doesn't make sense. Even numbers will round down, and odd numbers will round up. so 1.5>2, 2.5>2, 3.5>4,4.5>4.... and so on. What is happening here? I doubt this is something that I'll ever really use but I want to understand Labview as best I can. If anyone could shed light on this that would be awesome. 

 

q7.PNG

0 Kudos
Message 1 of 10
(4,264 Views)
Solution
Accepted by topic author CaveJohnson

I don't think the first question is supposed to be tricky, I think they made a mistake putting the "latching" picture in there.

 

For the second question, it is a common rounding rule (I think I learned it in a chemistry discussion of significant figures). Since you round 1, 2, 3, and 4 down, and you round 6, 7, 8, and 9 up, what do you do with 5? You round it to the nearest even number, with the idea being that "half" the time you round down, and "half" the time you round up.

Message 2 of 10
(4,240 Views)

Wow, apparently I have been rounding wrong my entire life. I have always rounded 5 up. I just looked it up and you are right, that's good to know, not just for labview lol. Thanks for taking the time to respond.

0 Kudos
Message 3 of 10
(4,236 Views)

IMHO, an "arbitrary rule" that .5 rounds to the nearest even number should never be on a CLAD (or other) test.  It is a completely arbitrary convention, not supported by Math or any other "reasonable" rule.  One should never have to adhere to such rules ...

 

I would (mathematically) expect Round to have the property "Round (X+1) = Round (X) + 1".  This is true for all values of X except X = N + 0.5 (where N is an integer).  A silly, illogical (to me) exception ...

 

Bob "Do the Math" Schor

Message 4 of 10
(4,163 Views)

I would have to agree with Bob_Shor and the IRS. 

 

“Round amounts of 50 cents or more up to the next whole dollar.”

0 Kudos
Message 5 of 10
(4,158 Views)

I agree. That's why I was so confused by it behaving that way. I was talking to people at work and they were saying that rounding convention makes sense with statistics where you don't want to compound all of the rounding up into some sort of error. Seems like a narrow case to make it a general rule.

0 Kudos
Message 6 of 10
(4,151 Views)

@Bob_Schor wrote:

It is a completely arbitrary convention, not supported by Math or any other "reasonable" rule.


Except it is in the IEEE standard.  If I remember correctly, Banker's Rounding is the preferred method according to the floating point IEEE standard.  This is for statistical reasons to reduce error.  There is actual math behind it, just don't ask me to do it (been 7 years since I have done any statistics).


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
0 Kudos
Message 7 of 10
(4,140 Views)

@crossrulz wrote:

@Bob_Schor wrote:

It is a completely arbitrary convention, not supported by Math or any other "reasonable" rule.


Except it is in the IEEE standard.  If I remember correctly, Banker's Rounding is the preferred method according to the floating point IEEE standard.  This is for statistical reasons to reduce error.  There is actual math behind it, just don't ask me to do it (been 7 years since I have done any statistics).


I just think of it as the number is statistically just as likely to be odd than even, therefore, it all evens out in the end (pun intended).  You wanted a more in-depth discussion of rounding?  Here it is.  Even if you didn't ask for it.  😉

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 8 of 10
(4,125 Views)

@jamiva wrote:

I would have to agree with Bob_Shor and the IRS. 

 

“Round amounts of 50 cents or more up to the next whole dollar.”


 

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 9 of 10
(4,121 Views)

@CaveJohnson wrote:

Wow, apparently I have been rounding wrong my entire life. I have always rounded 5 up. I just looked it up and you are right, that's good to know, not just for labview lol. Thanks for taking the time to respond.


Looking at the wikipedia page for IEEE_754, the standard only "defines" five rounding rules. As far as I know, it does not recommend one over the other.
 
 *Round toward 0
 *Round toward +∞
 *Round toward −∞
 *Round to nearest, ties to even
 *Round to nearest, ties away from zero

 

The OP said "Wow, apparently I have been rounding wrong my entire life". No he has not. The most important concept from that CLAD question is that this is how LabVIEW does it: "Round to nearest, ties to even". Most, but not all, programming languages use this rule. Some languages even support multiple rules.

 

Was this a good question to see if a CLAD candidate understands the concept? That's debatable. I hate coercion dots and try to avoid them at all cost. I know there has been other discussions that coercions are "faster, more efficient" than explicitly coding the conversion. But IMHO, I think clarity is more important than speed. I have been using LabVIEW for over 20 years and was not 100% sure what those dots implied. I quickly looked in the HELP file and didn't see anything about wiring a DBL to a case structure. This is what my code would look like. I know exactly what "To long Integer" does. I also added a few other rules.

 

I32 help .PNG

round to_.png

Message 10 of 10
(4,119 Views)