Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Why does labview not want to wait when comparing the same numbers?
Why does labview not want to wait when comparing the same numbers?

Floating point numbers are equal and not equal

This situation actually exists in every programming platform. The main reason lies in the decimal precision of floating point numbers. DBL is a double byte of 62 bits, and the precision is 15 bits. After more than 15 digits, it is an unknown state. Therefore, as in the block diagram above, we can think of these constants as 1, 0.002, and 3 as having fixed decimal places. But behind the addition function, there are actually an uncertain number of decimal places. Therefore, although we understand that 2.998+0.002 is theoretically equal to 3, in fact its value may be 3.000000000000000 in the memory. This way of expression, and the subsequent 16 decimal places of precision, there is no way to determine whether it is What's worth it. So here is the case of inequality. To solve this problem, you only need to do the function of forcing the number of decimal places after the addition. For example, if you force DBL to 3 decimal places, it will be equal to the following 3. Even if you force 15 decimal places, it will still be the same. It can be equal, but if you force 16 decimal places, it won't work. DBL has no way to express 16 decimal places.