<?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 How to get rid of extra decimal points during floating point calculations? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-get-rid-of-extra-decimal-points-during-floating-point/m-p/191763#M41090</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am making a script which takes a matrix as input, gets the interval between the elements in the matrix, and outputs that interval. My problem is that JMP output has extra decimal places sometimes (see log output below). How do I ensure that if my input has N decimal places, output should also have N decimal places?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;outmtx = [0, 0.2, 0.4, 0.6, 0.8, 1, 1.2, 1.4, 1.6, 1.8, 2,
		  2.2, 2.4, 2.6, 2.8, 3, 3.2, 3.4, 3.6, 3.8, 4,
		  4.2, 4.4, 4.6, 4.8, 5, 5.2, 5.4, 5.6, 5.8, 6,
		  6.2, 6.4, 6.6, 6.8, 7, 7.2, 7.4, 7.6, 7.8, 8,
		  8.2, 8.4, 8.6, 8.8, 9, 9.2, 9.4, 9.6, 9.8, 10];

mtxdiff = J(Nrows(outmtx)-1,1,0);		  

For (i=1, i&amp;lt;=Nrows(outmtx)-1, i++,  mtxdiff[i] = outmtx[i+1]-outmtx[i]);

Show(mtxdiff);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Log window output:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;mtxdiff = [0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2,&lt;BR /&gt; 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, &lt;BR /&gt;0.199999999999999, 0.2, 0.2, 0.2, 0.2, 0.199999999999999, 0.2, &lt;BR /&gt;0.2, 0.2, 0.2, 0.199999999999999, 0.2, 0.2, 0.2, 0.2, 0.199999999999999, &lt;BR /&gt;0.2, 0.2, 0.199999999999999, 0.200000000000001, 0.199999999999999,&lt;BR /&gt; 0.200000000000001, 0.199999999999999, 0.199999999999999, 0.200000000000001,&lt;BR /&gt; 0.199999999999999, 0.200000000000001, 0.199999999999999];&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Shaira&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 08 Apr 2019 02:03:23 GMT</pubDate>
    <dc:creator>shaira</dc:creator>
    <dc:date>2019-04-08T02:03:23Z</dc:date>
    <item>
      <title>How to get rid of extra decimal points during floating point calculations?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-get-rid-of-extra-decimal-points-during-floating-point/m-p/191763#M41090</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am making a script which takes a matrix as input, gets the interval between the elements in the matrix, and outputs that interval. My problem is that JMP output has extra decimal places sometimes (see log output below). How do I ensure that if my input has N decimal places, output should also have N decimal places?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;outmtx = [0, 0.2, 0.4, 0.6, 0.8, 1, 1.2, 1.4, 1.6, 1.8, 2,
		  2.2, 2.4, 2.6, 2.8, 3, 3.2, 3.4, 3.6, 3.8, 4,
		  4.2, 4.4, 4.6, 4.8, 5, 5.2, 5.4, 5.6, 5.8, 6,
		  6.2, 6.4, 6.6, 6.8, 7, 7.2, 7.4, 7.6, 7.8, 8,
		  8.2, 8.4, 8.6, 8.8, 9, 9.2, 9.4, 9.6, 9.8, 10];

mtxdiff = J(Nrows(outmtx)-1,1,0);		  

For (i=1, i&amp;lt;=Nrows(outmtx)-1, i++,  mtxdiff[i] = outmtx[i+1]-outmtx[i]);

Show(mtxdiff);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Log window output:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;mtxdiff = [0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2,&lt;BR /&gt; 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, &lt;BR /&gt;0.199999999999999, 0.2, 0.2, 0.2, 0.2, 0.199999999999999, 0.2, &lt;BR /&gt;0.2, 0.2, 0.2, 0.199999999999999, 0.2, 0.2, 0.2, 0.2, 0.199999999999999, &lt;BR /&gt;0.2, 0.2, 0.199999999999999, 0.200000000000001, 0.199999999999999,&lt;BR /&gt; 0.200000000000001, 0.199999999999999, 0.199999999999999, 0.200000000000001,&lt;BR /&gt; 0.199999999999999, 0.200000000000001, 0.199999999999999];&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Shaira&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2019 02:03:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-get-rid-of-extra-decimal-points-during-floating-point/m-p/191763#M41090</guid>
      <dc:creator>shaira</dc:creator>
      <dc:date>2019-04-08T02:03:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to get rid of extra decimal points during floating point calculations?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-get-rid-of-extra-decimal-points-during-floating-point/m-p/191801#M41093</link>
      <description>&lt;P&gt;See the Round() function. In this case, Round( mtxdiff, 1 ) should do what you want.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2019 08:58:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-get-rid-of-extra-decimal-points-during-floating-point/m-p/191801#M41093</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2019-04-08T08:58:44Z</dc:date>
    </item>
  </channel>
</rss>

