From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

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
(4,841 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
(4,832 Views)

Double.  Round up. Divide by 2.

 

Round to half.png

 

Lynn 

Message 3 of 7
(4,823 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
(4,542 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
(4,537 Views)

Thank you, very useful!

0 Kudos
Message 6 of 7
(4,532 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
(4,527 Views)