01-20-2016 03:49 AM
Hi everybody,
I just found a surprising error in Labview 2013. I want to get the interger part of the division of 2 float numbers: after the division I use the "floor" vi in the numerical palette. In some situations (with numbers below 1) this interger part is lower by 1 to what is should be. Example:
300m / 25m = 12.00 (division output)
floor(12.00) = 11.00
It seems to work only when both initial number are <1 and not in every configuration. I was wondering if it is some epsilon machine error in the calculation of the division
I'll use another solution for my calculation, but I think it may be corrected.
Regards.
01-20-2016 03:55 AM - edited 01-20-2016 04:01 AM
Hi Nico,
I was wondering if it is some epsilon machine error in the calculation of the division
Yes.
For clarity: set the display format of your floats to "%.20g" to see the reason of this "unexpected result"!
You will find a lot of threads handling rounding issues with floating point numbers, here in the forum as well as on Wikipedia!
Side note: why don't you use Quotient&Remainder function? It gives the same (flaky) result when used with DBLs…
01-20-2016 04:24 AM
Didn't went that far in looking at decimals.
Quotient and remainder function has the same problem yes.
I'll try to dig the forums to find solutions, but I think the most obvious is to multiply both number by 10^n with n chosen so that the number I get are intergers (no decimal part). And then I'll use the quotient and remainder function.
01-20-2016 04:28 AM
01-20-2016 04:53 AM - edited 01-20-2016 04:53 AM
Hum. Finally, I worked on mantissa and exponent, and added epsilon to division of the 2 mantissa. Seems to work without side effect. For the moment....
Many thanks for your help Gerd 🙂