01-22-2013 10:08 AM
Hi,
I would appreciate if someone could answer this question. Why 1 is divided by 2, the answer is 0 if the answer uses I32 data type? But 3 is divided by 2, the answer is 2 if the answer uses I32 data type? 5 is divided by 2, the answer is 2 if the answer uses I32 data type?
Thank you,
Steve
Solved! Go to Solution.
01-22-2013 10:13 AM
Because LabVIEW rounds x.5 to the even number. While I agree this is incredibly stupid and annoying, it gets its roots from IEEE 754: http://en.wikipedia.org/wiki/Rounding (search IEEE on that page).
01-22-2013 10:18 AM
As stated, rounding goes to the nearest even number when at X.5.
If you are dividing integers (and keeping with integers), you really should be using the Quotient & Remainder function instead.
01-22-2013 10:25 AM
Its called "Bankers rounding" and the correct IEEE 754 implementation since the divide is done as Floating point. However, if you want to stay in integer math use logical shift to multiply or divide by powers of two