LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Use of the "Equal?" function on floating point numbers is discouraged, yet the default terminals are type DBL. Why is that?

When you just grab the "Equal?" function off the palette and drop it in a BD, the default terminals are of type DBL.  I know that the function is polymorphic and will adapt to whatever you wire in, but it seems weird to me that the default form of this VI is a form that is actually strongly discouraged in practice. The Equals? help page even shows DBLs being wired into the function, while this white paper discourages that practice.

 

This default behavior seems like it could be misleading to those who don't know that it could fail, and seems to encourage wiring DBLs into "Equals." Is there a reason for this being the default?

Message 1 of 4
(3,126 Views)

Verywiseguy wrote: Is there a reason for this being the default?

Because the default for everything else is a DBL would be the only rationale I can think of.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 4
(3,104 Views)

The Equal function works just fine for Dbl.  The problem is that "measuring" (floats) is not as precise as "counting" (integers).  If I were to wire any legal float to both inputs of an Equals? function, I would get "True".  On the other hand, if I tried to compare the sine of 30° with 0.5, I would probably get "False", because (a) the representation of 30° in radians has limited precision, (b) the computation of sine(x) has limited precision, and (c) the representation of 0.5 (because it is an integral power of 2, namely 2^-1) is probably precise.  An imprecise function of an imprecise argument should not be expected to give a precise result.  Hence the warning.

 

Bob Schor

0 Kudos
Message 3 of 4
(3,041 Views)

@Verywiseguy wrote:

 

This default behavior seems like it could be misleading to those who don't know that it could fail, and seems to encourage wiring DBLs into "Equals." Is there a reason for this being the default?


You Could write a custom VIA Test for that and share it with the community- OverHere 


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 4
(3,026 Views)