01-21-2011 04:01 PM - edited 01-21-2011 04:03 PM
Because many fractional values cannot be fully represented in binary! For example if you keep adding 0.1 to a value and try to stop when the result is 1, it will never stop.
Since the origianl example here uses orange datatypes, I assume that the values don't necessarily are integers (else they would have selected an interger (blue) representation!)
For DBLs, equal comparisons (or not equal) are full of pitfalls. We could do a >3 instead of an =3 in this case.
There are plenty of discussions touching this, for example:
Read the entire threads!
01-21-2011 04:17 PM - edited 01-21-2011 04:18 PM
@Intelligent wrote:
Thanks gak
The thing is that, i have to search it only for the first time. And when that value is occurred now i have to do processing regardless 3 occurs again or not.
Here's a better example for that:

Initially the case is FALSE. Once the condition is met once, the TRUE case will always execute after that. (Modify as needed, e.g. add a way to reset ot back to off.)
01-22-2011 01:41 PM - edited 01-22-2011 01:42 PM
@altenbach wrote:
Because many fractional values cannot be fully represented in binary! For example if you keep adding 0.1 to a value and try to stop when the result is 1, it will never stop.
Since the origianl example here uses orange datatypes, I assume that the values don't necessarily are integers (else they would have selected an interger (blue) representation!)
For DBLs, equal comparisons (or not equal) are full of pitfalls. We could do a >3 instead of an =3 in this case.
There are plenty of discussions touching this, for example:
- http://forums.ni.com/t5/LabVIEW/5-1-5-is-not-equal-to-1/m-p/755915
- http://forums.ni.com/t5/LabVIEW/Bug-Two-Doubles-not-detected-as-equal-v8-6/m-p/1066548#M472944
- http://forums.ni.com/t5/LabVIEW/Search-1D-array-doesn-t-works/m-p/905518#M408089
- ... and many more.
Read the entire threads!
Sheesh. I have been around computers for longer than I care to admit. Ok it was even before IBM released their first PC. I have built computers and I am not talking about buying a power supply, motherboard, CPU and hard drive and putting them into a chassis. I mean that I built 6502 based systems using a wirewrapping tool and programmed the firmware using an EPROM programmer that I also built from scratch. I built a four function calculator from discrete TTL gates * and seven segment displays.
Yet this NEVER occured to me. I guess it must be the nature of the types of programs that I write. This is so blatantly obvious that I am embarased that I asked the question. But I always love these little embarasing moments for the simple reason that I actually learn something that I can guarantee that I will never forget.
* ok my calculater obviously didn't support floating point ![]()