LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW Equivilant to excel functions?

Solved!
Go to solution

For anyone who is interested in using what I call "conventional rounding," where everything greater than 0.5 is rounded up (statistically less accurate, but sometimes insisted upon by non-techies (i.e. management), here's some code I ripped from someplace here and put it in a drop-in replacement for the "Round to Nearest."  Whoever wrote this please come forward to take credit.

 Round To Conventional.JPG

 

 

 

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.
Message 11 of 17
(1,402 Views)

billko wrote:

For anyone who is interested in using what I call "conventional rounding," where everything greater than 0.5 is rounded up (statistically less accurate, but sometimes insisted upon by non-techies (i.e. management), here's some code I ripped from someplace here and put it in a drop-in replacement for the "Round to Nearest."  Whoever wrote this please come forward to take credit.

 Round To Conventional.JPG


What is it that you don't like at the "Round to Nearest" vi?

Because your code reacts just the same as that one!

 

x.000 to x.5000 result in x

x.50001 to x.99999 result in x+1

 

So I'm Smiley Surprised

0 Kudos
Message 12 of 17
(1,392 Views)

Alain S wrote:

billko wrote:

For anyone who is interested in using what I call "conventional rounding," where everything greater than 0.5 is rounded up (statistically less accurate, but sometimes insisted upon by non-techies (i.e. management), here's some code I ripped from someplace here and put it in a drop-in replacement for the "Round to Nearest."  Whoever wrote this please come forward to take credit.

 Round To Conventional.JPG


What is it that you don't like at the "Round to Nearest" vi?

Because your code reacts just the same as that one!

 

x.000 to x.5000 result in x

x.50001 to x.99999 result in x+1

 

So I'm Smiley Surprised


 

Technically.... and I mean very technically there is a slight difference.

His example rounds either up or down depending if it is > or < than 0.5


Round to nearest will round to the nearest even integer.

So 13.5 will round up to 14

But 12.5 will round down to 12.

 

But of course, 13.2 will round to 13 even if it is odd.

It only applies if the decimal is exactly 0.5


I believe this is the accepted method is statistics.

Message Edited by Cory K on 08-13-2009 12:59 PM
Cory K
0 Kudos
Message 13 of 17
(1,390 Views)
Oh, no - not THIS again.  Yes, it is not as statistically accurate as LabVIEW's rounding (called "banker's rounding," among other things), and I have indicated as much.  I *like* LabVIEW's rounding better, but some people (management, mostly) insist on using the old way because that's what they're used to so I made the little VI to appease the management gods...  😉
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 14 of 17
(1,381 Views)

billko wrote:
Oh, no - not THIS again.  Yes, it is not as statistically accurate as LabVIEW's rounding (called "banker's rounding," among other things), and I have indicated as much.  I *like* LabVIEW's rounding better, but some people (management, mostly) insist on using the old way because that's what they're used to so I made the little VI to appease the management gods...  😉

 

Yes, I agree that there are uses for both cases.
I was simply pointing out that there was a difference.

I also agree that you never want to upset your boss Smiley Wink

... dont bite the hand that feeds

Cory K
0 Kudos
Message 15 of 17
(1,378 Views)

Ha Ha! The first time I ever encounterred this issue I speculated that it was a bug. Its seem that no matter where you were schooled, we were all taught to "round up" to the nearest high number  (unless you are rounding a -ve number obviously).

 

The rounding standard that LabVIEW uses adheres to the IEEE 754 standard. There is loads of information on the web regarding the standard, but here is a link to the wiki article.

http://en.wikipedia.org/wiki/IEEE_754-2008#Roundings_to_nearest

 

Best wishes,

Rich Roberts
Senior Marketing Engineer, National Instruments
Connect on LinkedIn: https://www.linkedin.com/in/richard-roberts-4176a27b/
0 Kudos
Message 16 of 17
(1,344 Views)

Jeff Bohrer wrote:


So Round(x,d) will impement as round.PNG I missed the negate of d on the first shot

Message Edited by Jeff Bohrer on 08-13-2009 11:01 AM

Of course, the representation of control X should be DBL not I32! Smiley Surprised  or the function will be "pointless"


"Should be" isn't "Is" -Jay
0 Kudos
Message 17 of 17
(1,324 Views)