<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Condition error in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Condition-error/m-p/474025#M71888</link>
    <description>&lt;P&gt;it's not an issue for me, i like to do that&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 29 Mar 2022 08:23:55 GMT</pubDate>
    <dc:creator>AdamChoen</dc:creator>
    <dc:date>2022-03-29T08:23:55Z</dc:date>
    <item>
      <title>Condition error</title>
      <link>https://community.jmp.com/t5/Discussions/Condition-error/m-p/473087#M71773</link>
      <description>&lt;P&gt;hello&lt;BR /&gt;&lt;BR /&gt;I'm trying to do a delta check between neighboring cells value on the same column.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For( i = 1, i &amp;lt;= N Row( dtB ), i++,
    If(
        i == 1,
            If( Abs( :Delta[i] - :Delta[i + 1] ) &amp;lt;= 0.1,
                dtB:Check[i] = "Pass",
                dtB:Check[i] = "Fail"
            ),
        i == N Row( dtB ),
            If( Abs( :Delta[i] - :Delta[i - 1] ) &amp;lt;= 0.1,
                dtB:Check[i] = "Pass",
                dtB:Check[i] = "Fail"
            ),
        If( Abs( :Delta[i] - :Delta[i + 1] ) &amp;lt;= 0.1 | Abs( :Delta[i] - :Delta[i - 1] ) &amp;lt;= 0.1,
            dtB:Check[i] = "Pass",
            dtB:Check[i] = "Fail"
        )
    )
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;i get this result&lt;BR /&gt;&lt;BR /&gt;but line 5 should not fail&lt;BR /&gt;when I check it thru the log it seems like a bug or I'm missing something&lt;BR /&gt;appreciate your inputs&lt;BR /&gt;&lt;BR /&gt;i&lt;BR /&gt;/*:&lt;BR /&gt;&lt;BR /&gt;5&lt;BR /&gt;//:*/&lt;BR /&gt;:Delta[i]&lt;BR /&gt;/*:&lt;BR /&gt;&lt;BR /&gt;0.3&lt;BR /&gt;//:*/&lt;BR /&gt;:Delta[i+1]&lt;BR /&gt;/*:&lt;BR /&gt;&lt;BR /&gt;0.4&lt;BR /&gt;//:*/&lt;BR /&gt;abs(:Delta[i] - :Delta[i+1])&lt;BR /&gt;/*:&lt;BR /&gt;&lt;BR /&gt;0.1&lt;BR /&gt;//:*/&lt;BR /&gt;abs(:Delta[i] - :Delta[i+1]) &amp;lt;= 0.1&lt;BR /&gt;/*:&lt;BR /&gt;&lt;BR /&gt;0&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 18:14:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Condition-error/m-p/473087#M71773</guid>
      <dc:creator>AdamChoen</dc:creator>
      <dc:date>2023-06-09T18:14:20Z</dc:date>
    </item>
    <item>
      <title>Re: Condition error</title>
      <link>https://community.jmp.com/t5/Discussions/Condition-error/m-p/473111#M71776</link>
      <description>&lt;P&gt;If I understand what you are trying to do, then this simplified version might work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For Each Row(
	dtB:Check = If( Abs( :Delta - Lag(:Delta) ) &amp;lt;= 0.1, "Pass", "Fail" );
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 25 Mar 2022 13:50:15 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Condition-error/m-p/473111#M71776</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2022-03-25T13:50:15Z</dc:date>
    </item>
    <item>
      <title>Re: Condition error</title>
      <link>https://community.jmp.com/t5/Discussions/Condition-error/m-p/473113#M71777</link>
      <description>&lt;P&gt;abs(-0.4 - 0.3 ) = 0.7&lt;/P&gt;
&lt;P&gt;abs(-0.4) - abs(0.3) = 0.1&lt;/P&gt;</description>
      <pubDate>Fri, 25 Mar 2022 14:21:10 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Condition-error/m-p/473113#M71777</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2022-03-25T14:21:10Z</dc:date>
    </item>
    <item>
      <title>Re: Condition error</title>
      <link>https://community.jmp.com/t5/Discussions/Condition-error/m-p/473410#M71800</link>
      <description>&lt;P&gt;I like to check the cell value matching (up to 0.1) from both "sides" n+1 and n-1 in this column. 1st and last rows on one side.&lt;BR /&gt;thank you&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 26 Mar 2022 20:25:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Condition-error/m-p/473410#M71800</guid>
      <dc:creator>AdamChoen</dc:creator>
      <dc:date>2022-03-26T20:25:20Z</dc:date>
    </item>
    <item>
      <title>Re: Condition error</title>
      <link>https://community.jmp.com/t5/Discussions/Condition-error/m-p/473414#M71802</link>
      <description>&lt;P&gt;sorry, didn't get it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;i = 5;
:Delta[i] = 0.3;
:Delta[i+1] = 0.4;
abs(:Delta[i] - :Delta[i+1]) = 0.1;
// but 
abs(:Delta[i] - :Delta[i+1]) &amp;lt;= 0.1 // give me 0&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;why is that?&amp;nbsp;also&amp;nbsp;==&amp;nbsp;give&amp;nbsp;me&amp;nbsp;0,&amp;nbsp;&amp;gt;=&amp;nbsp;give&amp;nbsp;1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 26 Mar 2022 20:37:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Condition-error/m-p/473414#M71802</guid>
      <dc:creator>AdamChoen</dc:creator>
      <dc:date>2022-03-26T20:37:49Z</dc:date>
    </item>
    <item>
      <title>Re: Condition error</title>
      <link>https://community.jmp.com/t5/Discussions/Condition-error/m-p/473691#M71837</link>
      <description>&lt;P&gt;I confirm this error with the follow code (view results in Log):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;/* Abs( 0.4 - 0.3) == 0.1; returns 0 or false */

y = 0.1; x1 = 0.4; x2 = 0.3; diff = x1 - x2;
Show( y, x1, x2, diff, diff == 0.1 );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Mar 2022 12:48:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Condition-error/m-p/473691#M71837</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2022-03-28T12:48:46Z</dc:date>
    </item>
    <item>
      <title>Re: Condition error</title>
      <link>https://community.jmp.com/t5/Discussions/Condition-error/m-p/473700#M71840</link>
      <description>&lt;P&gt;One more thing to check would be the difference between diff and 0.1&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;diff - 0.1 = 2.77555756156289e-17;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;so floating number accuracy "problem"?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Round(diff, 1) == Round(0.1, 1) = 1;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Mar 2022 13:10:32 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Condition-error/m-p/473700#M71840</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-03-28T13:10:32Z</dc:date>
    </item>
    <item>
      <title>Re: Condition error</title>
      <link>https://community.jmp.com/t5/Discussions/Condition-error/m-p/473702#M71841</link>
      <description>&lt;P&gt;That's your basic floating point roundoff error.&amp;nbsp; Add an epsilon and it works:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Deltai = 0.3;
Deltai1 = 0.4;
epsilon = .000000001;
print(abs(Deltai - Deltai1));	// = 0.1;
print(abs(Deltai - Deltai1) &amp;lt;= 0.1);
print(abs(Deltai - Deltai1) &amp;lt;= 0.1 + epsilon);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;From the log:&lt;/P&gt;
&lt;PRE&gt;0.1
0
1&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Mar 2022 13:12:24 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Condition-error/m-p/473702#M71841</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2022-03-28T13:12:24Z</dc:date>
    </item>
    <item>
      <title>Re: Condition error</title>
      <link>https://community.jmp.com/t5/Discussions/Condition-error/m-p/473764#M71849</link>
      <description>&lt;P&gt;JMP Development confirmed that this is simply a finite precision numerical problem. Users are disturbed by floating point numbers that do not follow the math (e.g., subtraction). JMP tries to present the result as it is expected, but not the actual result in cases like yours (i.e., 0.4 - 0.3). They suggested also using this approach if you want a better view of the actual result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Format( 0.1, "Fixed Dec", 20, 22 );
Format( 0.4-0.3, "Fixed Dec", 20, 22 );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Mar 2022 13:58:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Condition-error/m-p/473764#M71849</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2022-03-28T13:58:38Z</dc:date>
    </item>
    <item>
      <title>Re: Condition error</title>
      <link>https://community.jmp.com/t5/Discussions/Condition-error/m-p/473775#M71855</link>
      <description>&lt;P&gt;The issue is that the difference from minus .4 to a positive .3 is .7.&amp;nbsp; The Absolute of the values are taken after the calculation!&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 14:35:04 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Condition-error/m-p/473775#M71855</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2022-03-28T14:35:04Z</dc:date>
    </item>
    <item>
      <title>Re: Condition error</title>
      <link>https://community.jmp.com/t5/Discussions/Condition-error/m-p/474025#M71888</link>
      <description>&lt;P&gt;it's not an issue for me, i like to do that&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 08:23:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Condition-error/m-p/474025#M71888</guid>
      <dc:creator>AdamChoen</dc:creator>
      <dc:date>2022-03-29T08:23:55Z</dc:date>
    </item>
    <item>
      <title>Re: Condition error</title>
      <link>https://community.jmp.com/t5/Discussions/Condition-error/m-p/474116#M71894</link>
      <description>&lt;P&gt;0.1 is a repeating fraction in binary. In IEEE floating point, it is rounded at 52 or 53 bits, so it must be either a bit too big or a bit too small.&lt;/P&gt;
&lt;P&gt;Good binary fractions are sums of&amp;nbsp; 1/2, 1/4, 1/8, 1/16, 1/32, ... 1/2^53 which are the individual bits of the fraction.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sometimes the "bit too big" or "bit too small" works out the way you want, and sometimes not.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The second example shows an epsilon chosen for numbers near 1, which have about 14 places after the decimal (thus 1e-12).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If( .3 - .2 == .1, // "no"
    "yes"
, // else
    "no"
);


If( Abs( (.3 - .2) - .1 ) &amp;lt; 1e-12, // "yes"
    "yes"
, // else
    "no"
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.jmp.com/t5/Discussions/strangeness-of-floating-point-math/m-p/270644/highlight/true#M52679" target="_self"&gt;Old post&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 13:56:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Condition-error/m-p/474116#M71894</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2022-03-29T13:56:17Z</dc:date>
    </item>
  </channel>
</rss>

