12-14-2016 11:33 PM
Hello guys ,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 ?
Solved! Go to Solution.
12-14-2016 11:49 PM
@Ahmed11 wrote:
So how to solve this rounding problem with even numbers ?
What "problem" are you trying to solve? What result do you expect instead?
12-14-2016 11:50 PM
I am expecting 179 not 178
12-14-2016 11:57 PM
Why?
12-14-2016 11:58 PM
I am trying to solve the rounding problem . I am expecting 179 not 178 , when the input is 3.5. Thank you
12-15-2016 12:01 AM
Because i am doing a analog to digital converter using lab view ( 8 bits analog to digital converter ) . So when i calculate the level of quantization i need to round it to the nearest integer . This is causing a problem for voltage values like 1.5 and 3.5 . Thank you
12-15-2016 01:03 AM
Bankers rounding is the default mode for IEEE 754 (see also), because if you would always round the x.5 up, you are creating a slight bias on average.
If you only have 8 bit resolution, you need to deal with certain limitations, and rouding is probably not the major issue. So you have 256 possible values. What is the voltage range you are trying to cover?
You can easily implement any kind if rounding you want (again, see here for the formulas). Since the possible values are so limited, you can even create a lookup table with 256 DBL and use the U8 value to index into it.
12-15-2016 05:48 AM
Thank you very much !
12-15-2016 08:41 AM
Dear altenbach , i am facing a new problem . As you know , i have used the formula (input*255/5) to convert to digital, then i have used digital to binary avi to convert this digital value to 8 bits.
The problem here is the data type mismatch between my output from the formula, which is a double data type and the input of the avi which is a digital data type, so how to solve this problem ? Thank you in advance
12-15-2016 10:52 AM
You can use the To Unsigned Byte function found in the Numeric->Convserion palette. Do this after your rounding.