LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why (-0.7 + 0.4) - (-0.3) is not 0 ?

Is it a bug? How can I avoid such problems when I use ">0" or "<0"?
My version is 7.0 and the vi is programmed in WinXP.
Thank you !
0 Kudos
Message 1 of 5
(3,099 Views)
Hi cactus
 
No, this is not a bug. This has to do with the management of floating point numbers in a computer.
 
Refer to this threads:
 
Hope this helps.
 
Thomas
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 2 of 5
(3,084 Views)
Roughly said, 0.7, 0.4 and 0.3 are not round numbers when expressed in the binary system. Your question can be translated as :
why 1 - 0.6666 - 0.3333 is not equal to 0 ?
This was one of the very first things that were taught one generation ago to students learning computer programming ;). I'm not sure if this is still the case nowaday, since this question appears quite often on this forum. 😄
 
Chilly Charly    (aka CC)
Message 3 of 5
(3,070 Views)
It is still this case nowadays. At least 4 years ago at the school I went to ;).
 
Thomas
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 4 of 5
(3,066 Views)
You can use the in Range and coerce vi and define your range of the region around 0 that fit your needs. Another way is to look for a change in the sign.
 
Don't mix up calculations (with uncertancy) and math Smiley Wink
 
You just learned by 'DOING'  (sound of a head hitting the door) Smiley Tongue
Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


Message 5 of 5
(3,022 Views)