Rounding in LABVIEW

2.2k views Asked by At

i am taking an input number from user and then i enter this input to a formula express block that contains this equation output=(input*255)/5 . We know that according to LABVIEW convention in rounding number that is halfway between two integer values , it rounds this number to the nearest even number . This means that if the number is already even , for example 178.5 the rounding will be 178 !! but if it is 177.5 , the rounding will be 178. So how to solve this rounding problem with even numbers ?

2

There are 2 answers

0
SeanJ On BEST ANSWER

You haven't stated your rounding preference but you could use round to + infinity or round to -infinity from the programming >> numeric toolbox

enter image description here

Here is the help for rounding to +inifinity

enter image description here

0
James On

You could use round down your number, subtract that from the unrounded number to get the fractional part, then check if that is greater than or equal to .5, in which case you add one to the rounded-down number.

Before you do that, be sure you are making the right choice. “LabVIEW convention” is the standard scientific/engineering convention for rounding numbers, and is so for a good reason: it prevents rounding causing statistical biases in calculations.