Skip to main content
8-Gravel
February 29, 2024
Solved

round numbers with units

  • February 29, 2024
  • 1 reply
  • 2229 views

hello,

im trying to get best wey to round numbers with units like 5.123456789 V

 

im using the function round(x)

but shows error for units not compatible

EP_10906526_0-1709233903367.png

 

need to use the rounded value to show on summary results

right now im using this functions to round and display the results

EP_10906526_4-1709234084721.png

 

 

 but this basically remove the units and convert my variable over and over to number and string, to be able to display it as result.

as you can see below

EP_10906526_3-1709234062388.png

 

but i want to show that result is actually 3.33 V 

I also have calculations for current, and capacitance, so I need function to keep different used units.

 

Best answer by Werner_E

For quantities with units you have to use  the "Round ( )" function - note the capital "R"

Werner_E_1-1709241715504.png

Syntax is different compared to the "round()" function - look it up in the help.

The second argument is not the number of decimals but with "Round" you round to multiples of the second argument. So 10^-2 V rounds multiples of 10 mV which is equivalent to two decimals in Volt.

See: Truncation and Rounding Functions

1 reply

21-Topaz II
February 29, 2024

Hi,'

Try round with a extra parameter being the number of decimal places

a=round(a,2)

Cheers

Terry

8-Gravel
February 29, 2024

Hello Terry

I tried but still not working

EP_10906526_0-1709238144162.png

😞

 

but thanks!

Werner_E25-Diamond IAnswer
25-Diamond I
February 29, 2024

For quantities with units you have to use  the "Round ( )" function - note the capital "R"

Werner_E_1-1709241715504.png

Syntax is different compared to the "round()" function - look it up in the help.

The second argument is not the number of decimals but with "Round" you round to multiples of the second argument. So 10^-2 V rounds multiples of 10 mV which is equivalent to two decimals in Volt.

See: Truncation and Rounding Functions