From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, 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: 

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,737 Views)
Solution
Accepted by topic author Doneen
Round(Locals.MyValue* 100 + .5) / 100
Message 2 of 4
(10,735 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,861 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,852 Views)