LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

5.1-5 is not equal to .1 ?

Hi all...
I'm using LabVIEW 8.5, When i tried to compare the result of difference of 5.1 and 5 (i.e 5.1-5) with .1 , the result was not equal. I used DBL representation.
Why is this so...?
0 Kudos
Message 1 of 3
(2,807 Views)
Your computer is binary, your number system is decimal. There will be rounding problems, using floating numbers for equality will get you into trouble. You should do an in range check of 0.1 +- 0.1 % or so. See wikipedia for more info.

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Message 2 of 3
(2,805 Views)
You could also multiply both input nuimbers by 10, convert them into integers, subtract them and test to see if the difference is equal to 1.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 3 of 3
(2,764 Views)