NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I round off a variable in Testsand?

Hi,
 
I want to round off a variable upto 3 decimal places form 5 decimals. (for e.g If it is 20.12388 I want it to be rounded off to 20.124).
I went to the properties of that particular variable. I clicked on Numeric format and changed number of fractional digits to 3. But it just trancated the last 2 digits instead of rounding off.
 
Do you know any way to round of a number?
 
Thanks,
Swal
0 Kudos
Message 1 of 4
(4,835 Views)
Swal,
 
It's kinda cludgey, but you can use this: Val(Str(Step.Result.Numeric, "%.3f"))
 
Hope this helps.
 
-Jack
Message 2 of 4
(4,821 Views)

or

Round(<your value> * 1000 + .5) / 1000

Replace 1000 with 10^<number of fractional digits desired>

 

Btw, changing the numeric format doesn't change the actual value, only how it is displayed.



Message Edited by James Grey on 04-07-2008 02:37 PM
0 Kudos
Message 3 of 4
(4,818 Views)
Thanks. This helped me a lot.
0 Kudos
Message 4 of 4
(4,784 Views)