# NI TestStand

cancel
Showing results for
Did you mean:

Solved!
Go to solution
Highlighted

## rounding after comma

How can I do this rounding?

Message 1 of 5
(247 Views)

## Re: rounding after comma

Up if equal to 5**

Message 2 of 5
(246 Views)
Highlighted

## Re: rounding after comma

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

Round(Locals.Roundee,0)

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

Message 3 of 5
(192 Views)
Highlighted

## Re: rounding after comma

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.

Message 4 of 5
(189 Views)
Highlighted
Solution
Accepted by topic author hkn10

## Re: rounding after comma

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

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Message 5 of 5
(172 Views)