NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Round a number to 2 decimal places

Solved!
Go to solution

Hi,

I have a computed value that returns 10 plus digits after the decimal place, exampe: 2.2482352941176.

What is the easiest way to edit this value in TestStand to return a number that is rounded up to 2 decimal places (2.25)?

Thanks & Regards,

Don1.

0 Kudos
Message 1 of 4
(10,758 Views)
Solution
Accepted by topic author Doneen
Round(Locals.MyValue* 100 + .5) / 100
Message 2 of 4
(10,756 Views)

That will only work for positive numbers

 

This should suit you for both positive and negative numbers

Round(Locals.MyValue* 100,4) / 100

 

 

Message 3 of 4
(9,882 Views)

One way to do this is to use the TestStand functions Str and Val.  The %.2f rounds the number to 2 decimal places.

 

Val(Str(Locals.MyValue, "%.2f"))

 

 

Peter

 

0 Kudos
Message 4 of 4
(9,873 Views)