topic Re: "minus zero" in numeric indicator in LabVIEW
https://forums.ni.com/t5/LabVIEW/quot-minus-zero-quot-in-numeric-indicator/m-p/1832047#M626947
<BLOCKQUOTE><HR /><LI-USER uid="33805"></LI-USER> wrote:<BR />
<P>If we start talking mathematics, we all agree that "-0" is the same number as "0".</P>
<P>. I'd rather go with adding zero and pray for the next SP to fix this.</P>
<P> </P>
<P>Thanks, Rod! </P>
<HR /></BLOCKQUOTE>
<P><BR />Actually -0 and +0 (while refering to the same quantity) have different encodings in memory and to the Computer are not the same. What you see as an "Inconsistancy" or a bug is actually the behavior required by IEEE-754 for floating point math operations. You may chose to disagree with the "correctness" of IEEE 754 but they (IEEE) are the definition of correct. If you wish to contact them and submit an abstract expressing the need to amend IEEE 754</P>
<P>Participation in IEEE standard development is easy- <A href="http://standards.ieee.org/develop/getinvolved.html" target="_self">according to this website</A>. </P>Tue, 10 Jan 2012 16:10:22 GMTJÞB2012-01-10T16:10:22Z"minus zero" in numeric indicator
https://forums.ni.com/t5/LabVIEW/quot-minus-zero-quot-in-numeric-indicator/m-p/1831859#M626915
<P>Hi,</P>
<P>just a general question:</P>
<P> </P>
<P>Since LabVIEW 2010 (I think) a numeric indicator displays "-0" if you devide zero by a negative number.</P>
<P>(Display format is "automatic formatting") </P>
<P> </P>
<P>e.g.: </P>
<P>0/-1=-0 (minus zero)</P>
<P>0/2 = 0</P>
<P> </P>
<P>There's nothing wrong with that , but my customers usually don't like that.</P>
<P>Is there an option to change that so that zero is zero (and not minus zero) ?</P>
<P> </P>
<P>Thanks! </P>Tue, 10 Jan 2012 14:41:33 GMThttps://forums.ni.com/t5/LabVIEW/quot-minus-zero-quot-in-numeric-indicator/m-p/1831859#M626915bef2012-01-10T14:41:33ZRe: "minus zero" in numeric indicator
https://forums.ni.com/t5/LabVIEW/quot-minus-zero-quot-in-numeric-indicator/m-p/1831947#M626923
<P>It's a bit of a kludge, but you could add zero!</P>
<P> </P>
<P>On my LV2009, I cast the result of the division onto a 64bit int, so I could see that 0/-1 (in double) really is -0 (double) [sign bit 1, all other bits zero]</P>
<P> </P>
<P>By adding double precision zero to the result, I get a clean zero, ie all bits zero.</P>
<P> </P>
<P>0 / -1 = -0</P>
<P>( 0 / -1 ) + 0 = 0</P>
<P> </P>
<P> </P>
<P> </P>
<P>Rod.</P>
<P> </P>Tue, 10 Jan 2012 15:25:04 GMThttps://forums.ni.com/t5/LabVIEW/quot-minus-zero-quot-in-numeric-indicator/m-p/1831947#M626923Rod422012-01-10T15:25:04ZRe: "minus zero" in numeric indicator
https://forums.ni.com/t5/LabVIEW/quot-minus-zero-quot-in-numeric-indicator/m-p/1831961#M626925
<P>Try to display at least 15 digits of the number. Most likely it is not exactly 0 but more something like -0.0000000000000123. This could be the effect of the different code generator used to compile the diagram into machine code. The generated floating code by the underlaying LLVM compiler that is used since 2009 or so, might generate significantly different machine code sequences that could explain such differences. Or it is really some other change in your own code that you haven't even noticed yet.</P>
<P> </P>
<P> </P>
<P>EDIT: I just see that this seems a more common problem and the set sign bit for a true 0, while logically not really wrong, is indeed a not so nice thing. Now the big question: Was that already known and will be fixed in 2011 SP1 or is that new, and then will most likely not even be changed in 2012.</P>Tue, 10 Jan 2012 15:32:19 GMThttps://forums.ni.com/t5/LabVIEW/quot-minus-zero-quot-in-numeric-indicator/m-p/1831961#M626925rolfk2012-01-10T15:32:19ZRe: "minus zero" in numeric indicator
https://forums.ni.com/t5/LabVIEW/quot-minus-zero-quot-in-numeric-indicator/m-p/1831969#M626927
<P>It is not necessarily something != 0. Due to the <A href="http://en.wikipedia.org/wiki/Double_precision" target="_blank">double precision</A>, there is a dedicated code for '-0'.</P>
<P> </P>
<P>While Rod's suggestion works (adding a positive zero), this "hack" has to be documented in your code!</P>
<P>The clean solution would be a comparison (remark: do not compare floating point against "==") and then compute the absolut value.</P>
<P> </P>
<P>hope this helps,</P>
<P>Norbert</P>Tue, 10 Jan 2012 15:35:50 GMThttps://forums.ni.com/t5/LabVIEW/quot-minus-zero-quot-in-numeric-indicator/m-p/1831969#M626927Norbert_B2012-01-10T15:35:50ZRe: "minus zero" in numeric indicator
https://forums.ni.com/t5/LabVIEW/quot-minus-zero-quot-in-numeric-indicator/m-p/1831985#M626931
<P>If we start talking mathematics, we all agree that "-0" is the same number as "0".</P>
<P>The signum bit is not cleared when deviding 0 by a negative number. ok.</P>
<P> </P>
<P>BUT: to be consistent: if you ADD zero to minus zero the solution should be minus zero: -0 + 0 = -0, just like -5 + 0 = -5.</P>
<P>So for me it feels like an inconsistency:</P>
<P>I a devision the signum bit is not cleared when the solution is truely zero. In additions the bit gets cleared.</P>
<P> </P>
<P>But this is going way too far. In the end it's just a display problem. And to be honest: I can't compare -0 against 0 every time I display a numeric. I'd rather go with adding zero and pray for the next SP to fix this.</P>
<P> </P>
<P>Thanks, Rod! </P>Tue, 10 Jan 2012 15:46:51 GMThttps://forums.ni.com/t5/LabVIEW/quot-minus-zero-quot-in-numeric-indicator/m-p/1831985#M626931bef2012-01-10T15:46:51ZRe: "minus zero" in numeric indicator
https://forums.ni.com/t5/LabVIEW/quot-minus-zero-quot-in-numeric-indicator/m-p/1832047#M626947
<BLOCKQUOTE><HR /><LI-USER uid="33805"></LI-USER> wrote:<BR />
<P>If we start talking mathematics, we all agree that "-0" is the same number as "0".</P>
<P>. I'd rather go with adding zero and pray for the next SP to fix this.</P>
<P> </P>
<P>Thanks, Rod! </P>
<HR /></BLOCKQUOTE>
<P><BR />Actually -0 and +0 (while refering to the same quantity) have different encodings in memory and to the Computer are not the same. What you see as an "Inconsistancy" or a bug is actually the behavior required by IEEE-754 for floating point math operations. You may chose to disagree with the "correctness" of IEEE 754 but they (IEEE) are the definition of correct. If you wish to contact them and submit an abstract expressing the need to amend IEEE 754</P>
<P>Participation in IEEE standard development is easy- <A href="http://standards.ieee.org/develop/getinvolved.html" target="_self">according to this website</A>. </P>Tue, 10 Jan 2012 16:10:22 GMThttps://forums.ni.com/t5/LabVIEW/quot-minus-zero-quot-in-numeric-indicator/m-p/1832047#M626947JÞB2012-01-10T16:10:22ZRe: "minus zero" in numeric indicator
https://forums.ni.com/t5/LabVIEW/quot-minus-zero-quot-in-numeric-indicator/m-p/1832097#M626956
<BLOCKQUOTE><HR /><LI-USER uid="9395"></LI-USER> Bohrer wrote:<BR />
<BLOCKQUOTE><HR /><LI-USER uid="33805"></LI-USER> wrote:<BR />
<P>If we start talking mathematics, we all agree that "-0" is the same number as "0".</P>
<P>. I'd rather go with adding zero and pray for the next SP to fix this.</P>
<P> </P>
<P>Thanks, Rod! </P>
<HR /></BLOCKQUOTE>
<P><BR />Actually -0 and +0 (while refering to the same quantity) have different encodings in memory and to the Computer are not the same. What you see as an "Inconsistancy" or a bug is actually the behavior required by IEEE-754 for floating point math operations. You may chose to disagree with the "correctness" of IEEE 754 but they (IEEE) are the definition of correct. If you wish to contact them and submit an abstract expressing the need to amend IEEE 754</P>
<P>Participation in IEEE standard development is easy- <A href="http://standards.ieee.org/develop/getinvolved.html" target="_self">according to this website</A>. </P>
<HR /></BLOCKQUOTE>
<P>I agree that the IEEE standard allows not only but provides two distinctive binary values to represent -0 and +0. This can be useful when calculating with certain formulas, but is in most everyday scenarios of little value. The fact that this seems to only show up in LabVIEW 2010 and newer also is an indication, that LabVIEW did it in the past differently. Most likely it has to do with the new LLVM machine code generator that was introduced in LabVIEW 2010. This code generator most likely does the "right thing" in terms of IEEE 754, but it isn't really intuitve to Joe average, and more importantly seems to be different than what it did before, when using the self cooked machine code generator.</P>Tue, 10 Jan 2012 16:36:18 GMThttps://forums.ni.com/t5/LabVIEW/quot-minus-zero-quot-in-numeric-indicator/m-p/1832097#M626956rolfk2012-01-10T16:36:18ZRe: "minus zero" in numeric indicator
https://forums.ni.com/t5/LabVIEW/quot-minus-zero-quot-in-numeric-indicator/m-p/1832119#M626960
<BLOCKQUOTE><HR /><LI-USER uid="6528"></LI-USER> wrote:<BR />
<P> [...] Most likely it is not exactly 0 but more something like -0.0000000000000123. This could be the effect of the different code generator used to compile the diagram [...]</P>
<HR />
<P> </P>
<P>This is where the "Approximately Equal to Zero" VI comes in handy. You have to write it yourself <img id="smileywink" class="emoticon emoticon-smileywink" src="https://forums.ni.com/i/smilies/16x16_smiley-wink.gif" alt="Smiley Wink" title="Smiley Wink" />, or I think Bloomy Controls has one. I like to have an input called "resolution limit". Example, wire a 5 to it, if there's 5 zeros to the right of the decimal, it outputs 0 and/or a Boolean True.</P>
</BLOCKQUOTE>
<P> </P>Tue, 10 Jan 2012 16:42:00 GMThttps://forums.ni.com/t5/LabVIEW/quot-minus-zero-quot-in-numeric-indicator/m-p/1832119#M626960Broken_Arrow2012-01-10T16:42:00ZRe: "minus zero" in numeric indicator
https://forums.ni.com/t5/LabVIEW/quot-minus-zero-quot-in-numeric-indicator/m-p/1832175#M626972
<P>I've looked back to earlier revisions of LabVIEW.</P>
<P> </P>
<P>As far back as at least 6.1, dividing 0 by -1 yields the bit pattern of 0x8000...., so the <STRONG>calculation</STRONG> returns "minus zero".</P>
<P> </P>
<P>In my 8.2, (EDIT: and 6.1, I don't have access to 7.x) the result is <STRONG>displayed </STRONG>as 0 with the default double precision indicator format, but as -0 in LV2009.</P>
<P> </P>
<P> </P>
<P>Rod.</P>
<P> </P>Tue, 10 Jan 2012 17:04:33 GMThttps://forums.ni.com/t5/LabVIEW/quot-minus-zero-quot-in-numeric-indicator/m-p/1832175#M626972Rod422012-01-10T17:04:33Z