From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

rounding after comma

Solved!
Go to solution
0 Kudos
Message 1 of 5
(1,247 Views)

Up if equal to 5**23d81993-dfd6-4332-9f67-1973abe64b39.jpg

0 Kudos
Message 2 of 5
(1,246 Views)

NOTE:  In both examples, Locals.Roundee is the number you want to round.

 

For your first examples

Round(Locals.Roundee,0)

 

For your second examples

Val(Str(Locals.Roundee, "%#.1f"))

0 Kudos
Message 3 of 5
(1,192 Views)

Doh! Just seen the "Up if 5" bit on your post.  My examples will "Down if 5".  I think if you want "Up if 5" that will be a pretty complicated statement.

0 Kudos
Message 4 of 5
(1,189 Views)
Solution
Accepted by hkn10

@SercoSteveB wrote:

Doh! Just seen the "Up if 5" bit on your post.  My examples will "Down if 5".  I think if you want "Up if 5" that will be a pretty complicated statement.


If you use 4 for the Round option, then it will use "banker's rounding" which will round 0.5 to the nearest even integer.  So for the second example use

Locals.Roundee = Round(Locals.Roundee*10,4)/10

 

To multiply and divide by 10 are to shift the decimal point (or comma) to the left before the round (to round to the nearest 0.1) and to the right to undo the shift after the rounding.


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
Message 5 of 5
(1,172 Views)