LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

SGL equality

Hola todos,
I use LabVIEW 7.1 at university on small test projects and really don't understand why, in LabVIEW,   3*34.4   is not equal to 103.2 ...

See my VI

Can somebody give me an explanation ???
Thanks in advance
0 Kudos
Message 1 of 2
(2,725 Views)

Hola DaviZ,

Smiley Very Happy Indeed.. That is funny, no ?

You've pointed an interesting problem, there is absolutely no bug and neither something wrong with LabVIEW.

Just keep in mind that in a computer, a number is just an array of byte (and one byte is 8 bits [0;1]).

So when it comes to floating numbers, the number you see is always an approximation with a given accuracy depending on the numeric representation (SGL in your case).

 

here is an exemple "almost equal.vi" just to play and explain the fact, have a look at it Smiley Wink

 

To fix this in your code, I know 2 different ways :

1. instead of "strictly equal to" use an "almost equal to" function in which you can set the accuracy you want.

2. or if you like playing with bytes, just put to 0, "small weight byte" (See attached "NUM_SGL....vi")

it only works with SGL numbers, but you can't get inspiration to develop the same kind of vi for DBL or whatever representation.



Smiley Wink


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

Download All
Message 2 of 2
(2,720 Views)