LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to round up or down to the significant digit

instead of nearest integer or infinify
0 Kudos
Message 1 of 5
(3,827 Views)
"AxE" wrote in message
news:50650000000800000023ED0000-1079395200000@exchange.ni.com...
> instead of nearest integer or infinify

Use number to fractional string with required # decimal places going to
precision input, then use fract/exp string to number. The first vi will
automatically round up or down.
0 Kudos
Message 2 of 5
(3,827 Views)
I also had this problem and used the same method as Adam.

Are there any other ways that are more elegant?
I tried type casting with a control with format specified but that did not work. Matlab has a round function, but I decided it would easier and quicker using the string conversion method.
0 Kudos
Message 3 of 5
(3,827 Views)
Hi,

Multiply with 10^decimal, then round, then devide again. Use an expression
node, with 10**x in it.

Regards,

Wiebe.


"Nick" wrote in message
news:50650000000500000045BA0100-1079395200000@exchange.ni.com...
> I also had this problem and used the same method as Adam.
>
> Are there any other ways that are more elegant?
> I tried type casting with a control with format specified but that did
> not work. Matlab has a round function, but I decided it would easier
> and quicker using the string conversion method.
0 Kudos
Message 4 of 5
(3,827 Views)
Thanks Wiebe. I knew there would be a better way but I didn't have time to think about it.

In the expression node use: int(10**y*x )/10**y
(x is your number and replace y with the number of decimal places you want.)
0 Kudos
Message 5 of 5
(3,827 Views)