LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

rounding to the next 0.5

I need to round a figure say 3.2 up to the nearest 0.5 so it will become 3.5 but i do not know how to do so as it always round to the nearest integer, from 3.2 to 4.

Need to know how to do round to 0.5 

Pls help.

Ty

0 Kudos
Message 1 of 7
(6,033 Views)

This will roundup anything above 3 but below 3.5 to 3.5.  From 3.5 to 4, it rounds up to 4.0.  However, due to representation errors, sometimes a .5 rounds up to the next integer, sometimes it doesn't.  For example, 10.5 will remain 10.5, but 9.5 will round up to 10.  At least that is how it does on my system.

 

RoundUp.png

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 7
(6,024 Views)

Double.  Round up. Divide by 2.

 

Round to half.png

 

Lynn 

Message 3 of 7
(6,015 Views)

And how to round to the nearest 0.5 multiple:

3.2 -> 3
3.6 -> 3.5
3.8 -> 4

0 Kudos
Message 4 of 7
(5,734 Views)

Hi troy,

 

double, round to nearest, divide by two...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 7
(5,729 Views)

Thank you, very useful!

0 Kudos
Message 6 of 7
(5,724 Views)

For the record MGI Librairies have this function and much much more.

 


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 7 of 7
(5,719 Views)