<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"  xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:access="http://www.bloglines.com/about/specs/fac-1.0">
  <access:restriction relationship="allow" />
  <channel>
    <title>Wikispaces : Liberty BASIC Programmer&#039;s Encyc - items matching description</title>
    <link>https://lbpe.wikispaces.com/space/view</link>
    <description>Filtered items at Wikispaces : Liberty BASIC Programmer&#039;s Encyc</description>
    
    <webMaster>help@wikispaces.com (Wikispaces)</webMaster>
    <generator>https://www.wikispaces.com/</generator>
    <ttl>60</ttl>
    <atom:link href="https://lbpe.wikispaces.com/space/xmlo?v=rss_2_0" rel="self" type="application/rss+xml" />
    <image>
      <title>Wikispaces : Liberty BASIC Programmer&#039;s Encyc - items matching description</title>
      <url>https://www.wikispaces.com/i/l.png</url>
      <link>https://lbpe.wikispaces.com/space/view</link>
      <width>140</width>
      <height>48</height>
      <description>Wikispaces</description>
    </image>

    <item>
      <title>Calculating the Value of PI</title>
      <link>https://lbpe.wikispaces.com/Calculating+the+Value+of+PI</link>
      <dc:creator>Alyce</dc:creator>
      <guid isPermaLink="true">https://lbpe.wikispaces.com/Calculating+the+Value+of+PI</guid>
      <comments>https://lbpe.wikispaces.com/page/messages/Calculating+the+Value+of+PI</comments>
      <pubDate>Wed, 30 May 2007 12:34:35 GMT</pubDate>
      <description>&lt;!-- ws:start:WikiTextHeadingRule:1:&amp;lt;h1&amp;gt; --&gt;&lt;h1 id=&quot;toc0&quot;&gt;&lt;a name=&quot;Using Liberty Basic to Calculate Pi with the Bailey-Borwein-Plouffe Algorithm&quot;&gt;&lt;/a&gt;&lt;!-- ws:end:WikiTextHeadingRule:1 --&gt;Using Liberty Basic to Calculate Pi with the Bailey-Borwein-Plouffe Algorithm&lt;/h1&gt;
 &lt;br /&gt;
An interesting exercise(and useful in technical calculations) is the determination of pi to a high degree of precision. One of the simplest of the algorithms for the calculation of pi is the Bailey-Borwein-Plouffe Algorithm.&lt;br /&gt;
&lt;br /&gt;
&lt;em&gt;Editor&#039;s note: for more detailed discussion, see Wikipedia &lt;a class=&quot;wiki_link_ext&quot; href=&quot;http://en.wikipedia.org/wiki/Bailey-Borwein-Plouffe_formula&quot; rel=&quot;nofollow&quot;&gt;Bailey-Borwein-Plouffe formula&lt;/a&gt; &lt;/em&gt;&lt;br /&gt;
&lt;br /&gt;
This code segment calculates the value of pi with accurate precision to 100 places. The more iterations performed, the deeper into the irrational number the precision may extend. With 100 places of precision the pi value may be considered accurate for any form of practical engineering or technical calculation.&lt;br /&gt;
&lt;!-- ws:start:WikiTextCodeRule:0:
&amp;lt;pre class=&amp;quot;text&amp;quot;&amp;gt;&#039;Program to calculate PI using the Bailey-Borwein-Plouffe Algorithm&amp;lt;br/&amp;gt;Print &amp;amp;quot;How many iterations to calculate (0-100)&amp;amp;quot;&amp;lt;br/&amp;gt;input iterations&amp;lt;br/&amp;gt;pi = 0&amp;lt;br/&amp;gt;if iterations &amp;amp;gt; 100 then goto [end]&amp;lt;br/&amp;gt;for n = 0 to iterations&amp;lt;br/&amp;gt;      pi = pi + (4/((8*n) + 1) - 2/((8*n)+4) - 1/((8*n)+5)_&amp;lt;br/&amp;gt;           - 1/((8*n)+6))*(1/16)^n&amp;lt;br/&amp;gt;next n&amp;lt;br/&amp;gt;print using (&amp;amp;quot;#.#############################################&amp;amp;quot;, pi)&amp;lt;br/&amp;gt;[end]input done&amp;lt;/pre&amp;gt;
 --&gt;
&lt;style type=&quot;text/css&quot;&gt;&lt;!--
/**
 * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
 * (http://qbnz.com/highlighter/ and http://geshi.org/)
 */
.text  {font-family:monospace;}
.text .imp {font-weight: bold; color: red;}
.text span.xtra { display:block; }

--&gt;
&lt;/style&gt;&lt;pre class=&quot;text&quot;&gt;&#039;Program to calculate PI using the Bailey-Borwein-Plouffe Algorithm
Print &amp;quot;How many iterations to calculate (0-100)&amp;quot;
input iterations
pi = 0
if iterations &amp;gt; 100 then goto [end]
for n = 0 to iterations
      pi = pi + (4/((8*n) + 1) - 2/((8*n)+4) - 1/((8*n)+5)_
           - 1/((8*n)+6))*(1/16)^n
next n
print using (&amp;quot;#.#############################################&amp;quot;, pi)
[end]input done&lt;/pre&gt;

&lt;!-- ws:end:WikiTextCodeRule:0 --&gt;&lt;br /&gt;
&lt;br /&gt;
Frank West&lt;br /&gt;
&lt;a class=&quot;wiki_link_ext&quot; href=&quot;mailto:frankdwest@yahoo.com&quot; rel=&quot;nofollow&quot;&gt;frankdwest@yahoo.com&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;hr /&gt;
See also: [[basic:Pi+a+la+modulus|Pi a la modulus]] by &lt;!-- ws:start:WikiTextUserlinkRule:01:[[user:harmonv]] --&gt;&lt;span class=&quot;membersnap&quot;&gt;- &lt;a class=&quot;userLink&quot; href=&quot;https://www.wikispaces.com/user/view/harmonv&quot; style=&quot;outline: none;&quot;&gt;&lt;img src=&quot;https://www.wikispaces.com/user/pic/harmonv-lg.jpg&quot; width=&quot;16&quot; height=&quot;16&quot; alt=&quot;harmonv&quot; class=&quot;userPicture&quot; /&gt;&lt;/a&gt; &lt;a class=&quot;userLink&quot; href=&quot;https://www.wikispaces.com/user/view/harmonv&quot; style=&quot;outline: none;&quot;&gt;harmonv&lt;/a&gt;&lt;/span&gt;&lt;!-- ws:end:WikiTextUserlinkRule:01 --&gt;</description>
          </item>
    <item>
      <title>IntegerArithmetic</title>
      <link>https://lbpe.wikispaces.com/IntegerArithmetic</link>
      <dc:creator>StPendl</dc:creator>
      <guid isPermaLink="true">https://lbpe.wikispaces.com/IntegerArithmetic</guid>
      <comments>https://lbpe.wikispaces.com/page/messages/IntegerArithmetic</comments>
      <pubDate>Sun, 17 Oct 2010 09:57:11 GMT</pubDate>
      <description>&lt;!-- ws:start:WikiTextHeadingRule:3:&amp;lt;h1&amp;gt; --&gt;&lt;h1 id=&quot;toc0&quot;&gt;&lt;a name=&quot;Integer Arithmetic&quot;&gt;&lt;/a&gt;&lt;!-- ws:end:WikiTextHeadingRule:3 --&gt;Integer Arithmetic&lt;/h1&gt;
 &lt;em&gt;&lt;!-- ws:start:WikiTextUserlinkRule:03:[[user:CarlGundel]] --&gt;&lt;span class=&quot;membersnap&quot;&gt;- &lt;a class=&quot;userLink&quot; href=&quot;https://www.wikispaces.com/user/view/CarlGundel&quot; style=&quot;outline: none;&quot;&gt;&lt;img src=&quot;https://www.wikispaces.com/user/pic/CarlGundel-lg.jpg&quot; width=&quot;16&quot; height=&quot;16&quot; alt=&quot;CarlGundel&quot; class=&quot;userPicture&quot; /&gt;&lt;/a&gt; &lt;a class=&quot;userLink&quot; href=&quot;https://www.wikispaces.com/user/view/CarlGundel&quot; style=&quot;outline: none;&quot;&gt;CarlGundel&lt;/a&gt;&lt;/span&gt;&lt;!-- ws:end:WikiTextUserlinkRule:03 --&gt;&lt;/em&gt;&lt;br /&gt;
&lt;!-- ws:start:WikiTextTocRule:11:&amp;lt;img id=&amp;quot;wikitext@@toc@@normal&amp;quot; class=&amp;quot;WikiMedia WikiMediaToc&amp;quot; title=&amp;quot;Table of Contents&amp;quot; src=&amp;quot;/site/embedthumbnail/toc/normal?w=225&amp;amp;h=100&amp;quot;/&amp;gt; --&gt;&lt;div id=&quot;toc&quot;&gt;&lt;h1 class=&quot;nopad&quot;&gt;Table of Contents&lt;/h1&gt;&lt;!-- ws:end:WikiTextTocRule:11 --&gt;&lt;!-- ws:start:WikiTextTocRule:12: --&gt;&lt;div style=&quot;margin-left: 1em;&quot;&gt;&lt;a href=&quot;#Integer Arithmetic&quot;&gt;Integer Arithmetic&lt;/a&gt;&lt;/div&gt;
&lt;!-- ws:end:WikiTextTocRule:12 --&gt;&lt;!-- ws:start:WikiTextTocRule:13: --&gt;&lt;div style=&quot;margin-left: 2em;&quot;&gt;&lt;a href=&quot;#Integer Arithmetic-Integer&quot;&gt;Integer&lt;/a&gt;&lt;/div&gt;
&lt;!-- ws:end:WikiTextTocRule:13 --&gt;&lt;!-- ws:start:WikiTextTocRule:14: --&gt;&lt;div style=&quot;margin-left: 2em;&quot;&gt;&lt;a href=&quot;#Integer Arithmetic-Floating Point&quot;&gt;Floating Point&lt;/a&gt;&lt;/div&gt;
&lt;!-- ws:end:WikiTextTocRule:14 --&gt;&lt;!-- ws:start:WikiTextTocRule:15: --&gt;&lt;div style=&quot;margin-left: 2em;&quot;&gt;&lt;a href=&quot;#Integer Arithmetic-Convert Float to Integer&quot;&gt;Convert Float to Integer&lt;/a&gt;&lt;/div&gt;
&lt;!-- ws:end:WikiTextTocRule:15 --&gt;&lt;!-- ws:start:WikiTextTocRule:16: --&gt;&lt;/div&gt;
&lt;!-- ws:end:WikiTextTocRule:16 --&gt;&lt;hr /&gt;
&lt;!-- ws:start:WikiTextHeadingRule:5:&amp;lt;h2&amp;gt; --&gt;&lt;h2 id=&quot;toc1&quot;&gt;&lt;a name=&quot;Integer Arithmetic-Integer&quot;&gt;&lt;/a&gt;&lt;!-- ws:end:WikiTextHeadingRule:5 --&gt;Integer&lt;/h2&gt;
 Liberty BASIC defaults to integer arithmetic unless you do something that produces a floating point result. For example:&lt;br /&gt;
&lt;br /&gt;
&lt;!-- ws:start:WikiTextCodeRule:0:
&amp;lt;pre class=&amp;quot;lb&amp;quot;&amp;gt;a = 3 + 4 &#039;integer calculation&amp;lt;br/&amp;gt;for x = 1 to 10 &#039;integer calculation&amp;lt;/pre&amp;gt;
 --&gt;
&lt;style type=&quot;text/css&quot;&gt;&lt;!--
/**
 * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
 * (http://qbnz.com/highlighter/ and http://geshi.org/)
 */
.lb  {font-family:monospace;}
.lb .imp {font-weight: bold; color: red;}
.lb .kw1 {color: #0000FF;}
.lb .kw2 {color: #AD0080;}
.lb .kw3 {color: #008080;}
.lb .co1 {color: #666666; font-style: italic;}
.lb .coMULTI {color: #666666; font-style: italic;}
.lb .es0 {color: #000099; font-weight: bold;}
.lb .br0 {color: #009900;}
.lb .sy1 {color: #339933;}
.lb .st0 {color: #008000;}
.lb .nu0 {color: #FF0000;}
.lb .me0 {color: #004000;}
.lb span.xtra { display:block; }

--&gt;
&lt;/style&gt;&lt;pre class=&quot;lb&quot;&gt;a &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;3&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;4&lt;/span&gt; &lt;span class=&quot;co1&quot;&gt;&#039;integer calculation&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;for&lt;/span&gt; x &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;to&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;10&lt;/span&gt; &lt;span class=&quot;co1&quot;&gt;&#039;integer calculation&lt;/span&gt;&lt;/pre&gt;

&lt;!-- ws:end:WikiTextCodeRule:0 --&gt;&lt;br /&gt;
&lt;!-- ws:start:WikiTextHeadingRule:7:&amp;lt;h2&amp;gt; --&gt;&lt;h2 id=&quot;toc2&quot;&gt;&lt;a name=&quot;Integer Arithmetic-Floating Point&quot;&gt;&lt;/a&gt;&lt;!-- ws:end:WikiTextHeadingRule:7 --&gt;Floating Point&lt;/h2&gt;
Or floating point:&lt;br /&gt;
&lt;br /&gt;
&lt;!-- ws:start:WikiTextCodeRule:1:
&amp;lt;pre class=&amp;quot;lb&amp;quot;&amp;gt;a = 0.3 + 0.4 &#039;floating point&amp;lt;/pre&amp;gt;
 --&gt;
&lt;style type=&quot;text/css&quot;&gt;&lt;!--
/**
 * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
 * (http://qbnz.com/highlighter/ and http://geshi.org/)
 */
.lb  {font-family:monospace;}
.lb .imp {font-weight: bold; color: red;}
.lb .kw1 {color: #0000FF;}
.lb .kw2 {color: #AD0080;}
.lb .kw3 {color: #008080;}
.lb .co1 {color: #666666; font-style: italic;}
.lb .coMULTI {color: #666666; font-style: italic;}
.lb .es0 {color: #000099; font-weight: bold;}
.lb .br0 {color: #009900;}
.lb .sy1 {color: #339933;}
.lb .st0 {color: #008000;}
.lb .nu0 {color: #FF0000;}
.lb .me0 {color: #004000;}
.lb span.xtra { display:block; }

--&gt;
&lt;/style&gt;&lt;pre class=&quot;lb&quot;&gt;a &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0.3&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0.4&lt;/span&gt; &lt;span class=&quot;co1&quot;&gt;&#039;floating point&lt;/span&gt;&lt;/pre&gt;

&lt;!-- ws:end:WikiTextCodeRule:1 --&gt;&lt;br /&gt;
&lt;!-- ws:start:WikiTextHeadingRule:9:&amp;lt;h2&amp;gt; --&gt;&lt;h2 id=&quot;toc3&quot;&gt;&lt;a name=&quot;Integer Arithmetic-Convert Float to Integer&quot;&gt;&lt;/a&gt;&lt;!-- ws:end:WikiTextHeadingRule:9 --&gt;Convert Float to Integer&lt;/h2&gt;
If a floating point result has a zero fractional part (this doesn&#039;t happen too often), then LB will convert it to an integer number on assignment. This is dependent on the math processor, and probably other variables.&lt;br /&gt;
&lt;br /&gt;
&lt;!-- ws:start:WikiTextCodeRule:2:
&amp;lt;pre class=&amp;quot;lb&amp;quot;&amp;gt;a = 0.3 + 0.7 &#039;may become an integer on assignment&amp;lt;/pre&amp;gt;
 --&gt;
&lt;style type=&quot;text/css&quot;&gt;&lt;!--
/**
 * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
 * (http://qbnz.com/highlighter/ and http://geshi.org/)
 */
.lb  {font-family:monospace;}
.lb .imp {font-weight: bold; color: red;}
.lb .kw1 {color: #0000FF;}
.lb .kw2 {color: #AD0080;}
.lb .kw3 {color: #008080;}
.lb .co1 {color: #666666; font-style: italic;}
.lb .coMULTI {color: #666666; font-style: italic;}
.lb .es0 {color: #000099; font-weight: bold;}
.lb .br0 {color: #009900;}
.lb .sy1 {color: #339933;}
.lb .st0 {color: #008000;}
.lb .nu0 {color: #FF0000;}
.lb .me0 {color: #004000;}
.lb span.xtra { display:block; }

--&gt;
&lt;/style&gt;&lt;pre class=&quot;lb&quot;&gt;a &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0.3&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0.7&lt;/span&gt; &lt;span class=&quot;co1&quot;&gt;&#039;may become an integer on assignment&lt;/span&gt;&lt;/pre&gt;

&lt;!-- ws:end:WikiTextCodeRule:2 --&gt;&lt;br /&gt;
-Carl</description>
          </item>
    <item>
      <title>math</title>
      <link>https://lbpe.wikispaces.com/math</link>
      <dc:creator>Alyce</dc:creator>
      <guid isPermaLink="true">https://lbpe.wikispaces.com/math</guid>
      <comments>https://lbpe.wikispaces.com/page/messages/math</comments>
      <pubDate>Mon, 23 Jan 2012 20:48:47 GMT</pubDate>
      <description>&lt;!-- ws:start:WikiTextHeadingRule:0:&amp;lt;h1&amp;gt; --&gt;&lt;h1 id=&quot;toc0&quot;&gt;&lt;a name=&quot;Numbers and Math&quot;&gt;&lt;/a&gt;&lt;!-- ws:end:WikiTextHeadingRule:0 --&gt;Numbers and Math&lt;/h1&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;a class=&quot;wiki_link&quot; href=&quot;/IntegerArithmetic&quot;&gt;Integer Arithmetic&lt;/a&gt; - &lt;!-- ws:start:WikiTextUserlinkRule:00:[[user:CarlGundel]] --&gt;&lt;span class=&quot;membersnap&quot;&gt;- &lt;a class=&quot;userLink&quot; href=&quot;https://www.wikispaces.com/user/view/CarlGundel&quot; style=&quot;outline: none;&quot;&gt;&lt;img src=&quot;https://www.wikispaces.com/user/pic/CarlGundel-lg.jpg&quot; width=&quot;16&quot; height=&quot;16&quot; alt=&quot;CarlGundel&quot; class=&quot;userPicture&quot; /&gt;&lt;/a&gt; &lt;a class=&quot;userLink&quot; href=&quot;https://www.wikispaces.com/user/view/CarlGundel&quot; style=&quot;outline: none;&quot;&gt;CarlGundel&lt;/a&gt;&lt;/span&gt;&lt;!-- ws:end:WikiTextUserlinkRule:00 --&gt;&lt;/li&gt;&lt;li&gt;&lt;a class=&quot;wiki_link&quot; href=&quot;/Scientific%20precision&quot;&gt;Precision and Scientific Notation in Liberty BASIC&lt;/a&gt; - &lt;!-- ws:start:WikiTextUserlinkRule:01:[[user:GrahameKing]] --&gt;&lt;span class=&quot;membersnap&quot;&gt;- &lt;a class=&quot;userLink&quot; href=&quot;https://www.wikispaces.com/user/view/GrahameKing&quot; style=&quot;outline: none;&quot;&gt;&lt;img src=&quot;https://www.wikispaces.com/user/pic/GrahameKing-lg.jpg&quot; width=&quot;16&quot; height=&quot;16&quot; alt=&quot;GrahameKing&quot; class=&quot;userPicture&quot; /&gt;&lt;/a&gt; &lt;a class=&quot;userLink&quot; href=&quot;https://www.wikispaces.com/user/view/GrahameKing&quot; style=&quot;outline: none;&quot;&gt;GrahameKing&lt;/a&gt;&lt;/span&gt;&lt;!-- ws:end:WikiTextUserlinkRule:01 --&gt;&lt;/li&gt;&lt;li&gt;&lt;a class=&quot;wiki_link&quot; href=&quot;/Bit.Shift&quot;&gt;Bit Shift Functions&lt;/a&gt; - &lt;!-- ws:start:WikiTextUserlinkRule:02:[[user:CarlGundel]] --&gt;&lt;span class=&quot;membersnap&quot;&gt;- &lt;a class=&quot;userLink&quot; href=&quot;https://www.wikispaces.com/user/view/CarlGundel&quot; style=&quot;outline: none;&quot;&gt;&lt;img src=&quot;https://www.wikispaces.com/user/pic/CarlGundel-lg.jpg&quot; width=&quot;16&quot; height=&quot;16&quot; alt=&quot;CarlGundel&quot; class=&quot;userPicture&quot; /&gt;&lt;/a&gt; &lt;a class=&quot;userLink&quot; href=&quot;https://www.wikispaces.com/user/view/CarlGundel&quot; style=&quot;outline: none;&quot;&gt;CarlGundel&lt;/a&gt;&lt;/span&gt;&lt;!-- ws:end:WikiTextUserlinkRule:02 --&gt;&lt;/li&gt;&lt;li&gt;&lt;a class=&quot;wiki_link&quot; href=&quot;/Calculating%20the%20Value%20of%20PI&quot;&gt;Calculating the Value of PI&lt;/a&gt; - &lt;!-- ws:start:WikiTextUserlinkRule:03:[[user:frankdwest]] --&gt;&lt;span class=&quot;membersnap&quot;&gt;- &lt;a class=&quot;userLink&quot; href=&quot;https://www.wikispaces.com/user/view/frankdwest&quot; style=&quot;outline: none;&quot;&gt;&lt;img src=&quot;https://www.wikispaces.com/user/pic/frankdwest-lg.jpg&quot; width=&quot;16&quot; height=&quot;16&quot; alt=&quot;frankdwest&quot; class=&quot;userPicture&quot; /&gt;&lt;/a&gt; &lt;a class=&quot;userLink&quot; href=&quot;https://www.wikispaces.com/user/view/frankdwest&quot; style=&quot;outline: none;&quot;&gt;frankdwest&lt;/a&gt;&lt;/span&gt;&lt;!-- ws:end:WikiTextUserlinkRule:03 --&gt;&lt;/li&gt;&lt;li&gt;&lt;a class=&quot;wiki_link&quot; href=&quot;/Numbers%20in%20LB&quot;&gt;Numbers in LB&lt;/a&gt; - &lt;!-- ws:start:WikiTextUserlinkRule:04:[[user:tsh73]] --&gt;&lt;span class=&quot;membersnap&quot;&gt;- &lt;a class=&quot;userLink&quot; href=&quot;https://www.wikispaces.com/user/view/tsh73&quot; style=&quot;outline: none;&quot;&gt;&lt;img src=&quot;https://www.wikispaces.com/user/pic/tsh73-lg.jpg&quot; width=&quot;16&quot; height=&quot;16&quot; alt=&quot;tsh73&quot; class=&quot;userPicture&quot; /&gt;&lt;/a&gt; &lt;a class=&quot;userLink&quot; href=&quot;https://www.wikispaces.com/user/view/tsh73&quot; style=&quot;outline: none;&quot;&gt;tsh73&lt;/a&gt;&lt;/span&gt;&lt;!-- ws:end:WikiTextUserlinkRule:04 --&gt;&lt;/li&gt;&lt;/ul&gt;</description>
          </item>
    <item>
      <title>Scientific precision</title>
      <link>https://lbpe.wikispaces.com/Scientific+precision</link>
      <dc:creator>GrahameKing</dc:creator>
      <guid isPermaLink="true">https://lbpe.wikispaces.com/Scientific+precision</guid>
      <comments>https://lbpe.wikispaces.com/page/messages/Scientific+precision</comments>
      <pubDate>Thu, 24 Aug 2006 05:28:33 GMT</pubDate>
      <description>&lt;!-- ws:start:WikiTextTocRule:22:&amp;lt;img id=&amp;quot;wikitext@@toc@@normal&amp;quot; class=&amp;quot;WikiMedia WikiMediaToc&amp;quot; title=&amp;quot;Table of Contents&amp;quot; src=&amp;quot;/site/embedthumbnail/toc/normal?w=225&amp;amp;h=100&amp;quot;/&amp;gt; --&gt;&lt;div id=&quot;toc&quot;&gt;&lt;h1 class=&quot;nopad&quot;&gt;Table of Contents&lt;/h1&gt;&lt;!-- ws:end:WikiTextTocRule:22 --&gt;&lt;!-- ws:start:WikiTextTocRule:23: --&gt;&lt;div style=&quot;margin-left: 1em;&quot;&gt;&lt;a href=&quot;#Precision and Scientific Notation in Liberty BASIC&quot;&gt;Precision and Scientific Notation in Liberty BASIC&lt;/a&gt;&lt;/div&gt;
&lt;!-- ws:end:WikiTextTocRule:23 --&gt;&lt;!-- ws:start:WikiTextTocRule:24: --&gt;&lt;div style=&quot;margin-left: 2em;&quot;&gt;&lt;a href=&quot;#Precision and Scientific Notation in Liberty BASIC-Precision and Rounding&quot;&gt;Precision and Rounding&lt;/a&gt;&lt;/div&gt;
&lt;!-- ws:end:WikiTextTocRule:24 --&gt;&lt;!-- ws:start:WikiTextTocRule:25: --&gt;&lt;div style=&quot;margin-left: 2em;&quot;&gt;&lt;a href=&quot;#Precision and Scientific Notation in Liberty BASIC-Precision and Accuracy&quot;&gt;Precision and Accuracy&lt;/a&gt;&lt;/div&gt;
&lt;!-- ws:end:WikiTextTocRule:25 --&gt;&lt;!-- ws:start:WikiTextTocRule:26: --&gt;&lt;div style=&quot;margin-left: 2em;&quot;&gt;&lt;a href=&quot;#Precision and Scientific Notation in Liberty BASIC-Scientific Notation&quot;&gt;Scientific Notation&lt;/a&gt;&lt;/div&gt;
&lt;!-- ws:end:WikiTextTocRule:26 --&gt;&lt;!-- ws:start:WikiTextTocRule:27: --&gt;&lt;div style=&quot;margin-left: 2em;&quot;&gt;&lt;a href=&quot;#Precision and Scientific Notation in Liberty BASIC-General Function for Scientific Notation&quot;&gt;General Function for Scientific Notation&lt;/a&gt;&lt;/div&gt;
&lt;!-- ws:end:WikiTextTocRule:27 --&gt;&lt;!-- ws:start:WikiTextTocRule:28: --&gt;&lt;div style=&quot;margin-left: 2em;&quot;&gt;&lt;a href=&quot;#Precision and Scientific Notation in Liberty BASIC-General Rounding Function&quot;&gt;General Rounding Function&lt;/a&gt;&lt;/div&gt;
&lt;!-- ws:end:WikiTextTocRule:28 --&gt;&lt;!-- ws:start:WikiTextTocRule:29: --&gt;&lt;div style=&quot;margin-left: 2em;&quot;&gt;&lt;a href=&quot;#Precision and Scientific Notation in Liberty BASIC-What&#039;s Wrong with Using USING() for Rounding?&quot;&gt;What&#039;s Wrong with Using USING() for Rounding?&lt;/a&gt;&lt;/div&gt;
&lt;!-- ws:end:WikiTextTocRule:29 --&gt;&lt;!-- ws:start:WikiTextTocRule:30: --&gt;&lt;div style=&quot;margin-left: 2em;&quot;&gt;&lt;a href=&quot;#Precision and Scientific Notation in Liberty BASIC-Beyond Double Precision&quot;&gt;Beyond Double Precision&lt;/a&gt;&lt;/div&gt;
&lt;!-- ws:end:WikiTextTocRule:30 --&gt;&lt;!-- ws:start:WikiTextTocRule:31: --&gt;&lt;/div&gt;
&lt;!-- ws:end:WikiTextTocRule:31 --&gt;&lt;!-- ws:start:WikiTextHeadingRule:6:&amp;lt;h1&amp;gt; --&gt;&lt;h1 id=&quot;toc0&quot;&gt;&lt;a name=&quot;Precision and Scientific Notation in Liberty BASIC&quot;&gt;&lt;/a&gt;&lt;!-- ws:end:WikiTextHeadingRule:6 --&gt;Precision and Scientific Notation in Liberty BASIC&lt;/h1&gt;
Reproduced with minor editing from Newsletter 139&lt;br /&gt;
copyright 2005, Grahame King&lt;br /&gt;
&lt;br /&gt;
This is a brief outline of the most a Liberty BASIC programmer is likely to need to know about precision and scientific notation. This article will probably be of most interest to science students and includes functions they can incorporate into their programs for outputting numbers in scientific notation.&lt;br /&gt;
&lt;br /&gt;
&lt;!-- ws:start:WikiTextHeadingRule:8:&amp;lt;h2&amp;gt; --&gt;&lt;h2 id=&quot;toc1&quot;&gt;&lt;a name=&quot;Precision and Scientific Notation in Liberty BASIC-Precision and Rounding&quot;&gt;&lt;/a&gt;&lt;!-- ws:end:WikiTextHeadingRule:8 --&gt;Precision and Rounding&lt;/h2&gt;
&lt;br /&gt;
ALL numbers in Liberty BASIC are stored and manipulated in double precision. This means that if there is an error from the computer&#039;s limit on how many decimal places it can keep, it will appear in the 15th digit after the decimal point. Missing a few points at the fifteenth decimal is the equivalent of a few people going missing out of a population about 500,000 times the earth&#039;s population. Accurate enough for government work and even most scientific and engineering work.&lt;br /&gt;
&lt;br /&gt;
Such tiny errors can occur with no calculation as soon as the data is input because of the way numbers are stored internally, particularly the limited amount of storage devoted to the part of the number after the decimal point. Such errors have been demonstrated in the conforums posts in threads on &amp;quot;Rounding&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Rounding, as most readers will know, is a controlled lowering of precision by &amp;quot;correcting&amp;quot; to the nearest whole number of a specified position in the decimal representation. To see this in action, run the final demo below.&lt;br /&gt;
&lt;br /&gt;
You can most simply output numbers to the desired precision, using the USING() function of LB. If you never use more than 14 # characters after the decimal point you will never see these tiny errors - and why would you want to?&lt;br /&gt;
&lt;br /&gt;
Once again, see the final demo in this article for an example of rounding.&lt;br /&gt;
&lt;br /&gt;
&lt;!-- ws:start:WikiTextHeadingRule:10:&amp;lt;h2&amp;gt; --&gt;&lt;h2 id=&quot;toc2&quot;&gt;&lt;a name=&quot;Precision and Scientific Notation in Liberty BASIC-Precision and Accuracy&quot;&gt;&lt;/a&gt;&lt;!-- ws:end:WikiTextHeadingRule:10 --&gt;Precision and Accuracy&lt;/h2&gt;
&lt;br /&gt;
There is a technical distinction between precision and accuracy. Accuracy refers to the degree of error potentially inherent in a measurement. Precision is about the amount of fine information in the numerical expression of the measurement. You can have a high precision expression of a low accuracy measurement - very misleading at best. And you can have a low precision expression of a highly accurate measurement - possibly a bit wasteful of good information. The two terms are sometimes used interchangeably.&lt;br /&gt;
&lt;br /&gt;
&lt;!-- ws:start:WikiTextHeadingRule:12:&amp;lt;h2&amp;gt; --&gt;&lt;h2 id=&quot;toc3&quot;&gt;&lt;a name=&quot;Precision and Scientific Notation in Liberty BASIC-Scientific Notation&quot;&gt;&lt;/a&gt;&lt;!-- ws:end:WikiTextHeadingRule:12 --&gt;Scientific Notation&lt;/h2&gt;
&lt;br /&gt;
For very large and very small numbers, scientists long ago agreed on a standard way of representing them so that they would all be easily able to compare results. This became the standard for all numbers in scientific and engineering journals.&lt;br /&gt;
&lt;br /&gt;
The syntax is:&lt;br /&gt;
&lt;br /&gt;
D.d{d}eN&lt;br /&gt;
&lt;br /&gt;
D - is a single digit between 1 and 9 before the decimal point&lt;br /&gt;
d - represents digits after the decimal point which may be zero&lt;br /&gt;
e - is the letter &amp;quot;e&amp;quot;&lt;br /&gt;
N - is a positive or negative integer called the exponent representing the power of ten to multiply by&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
1.234e3 &lt;!-- ws:start:WikiTextRawRule:00:``=`` --&gt;=&lt;!-- ws:end:WikiTextRawRule:00 --&gt; 1.234 x 10 x 10 x 10 &lt;!-- ws:start:WikiTextRawRule:01:``=`` --&gt;=&lt;!-- ws:end:WikiTextRawRule:01 --&gt; 1.234 x 1000 = 1234&lt;br /&gt;
9.67e-7 &lt;!-- ws:start:WikiTextRawRule:02:``=`` --&gt;=&lt;!-- ws:end:WikiTextRawRule:02 --&gt; 9.67 x (1/10000000) &lt;!-- ws:start:WikiTextRawRule:03:``=`` --&gt;=&lt;!-- ws:end:WikiTextRawRule:03 --&gt; 0.000000967&lt;br /&gt;
&lt;br /&gt;
So a positive exponent means &amp;quot;shift the decimal point this many places to the right&amp;quot;&lt;br /&gt;
&lt;br /&gt;
and a negative exponent means &amp;quot;shift the decimal point this many places to the left&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
We can represent any number in this form except zero. The scientific notation for zero is 0 - though some sticklers may put 0e0.&lt;br /&gt;
&lt;br /&gt;
The part of the number before the &amp;quot;e&amp;quot; is usually called the mantissa but may also be called the significand (sic).&lt;br /&gt;
&lt;br /&gt;
&lt;!-- ws:start:WikiTextHeadingRule:14:&amp;lt;h2&amp;gt; --&gt;&lt;h2 id=&quot;toc4&quot;&gt;&lt;a name=&quot;Precision and Scientific Notation in Liberty BASIC-General Function for Scientific Notation&quot;&gt;&lt;/a&gt;&lt;!-- ws:end:WikiTextHeadingRule:14 --&gt;General Function for Scientific Notation&lt;/h2&gt;
&lt;br /&gt;
The following LB function will represent any number (positive or negative or zero) in scientific notation.&lt;br /&gt;
&lt;br /&gt;
Try entering any numbers you want. Note especially how the system represents small numbers like 0.0000000000067 in an exponential form but not the standard scientific notation. The function given will &amp;quot;fix&amp;quot; these and will accept any non-standard exponential form such as 234.76e-7 thanks to the latest expansion of LB.&lt;br /&gt;
&lt;br /&gt;
&lt;!-- ws:start:WikiTextCodeRule:4:
&amp;lt;pre class=&amp;quot;vbnet&amp;quot;&amp;gt;&#039; test program for scientific notation function&amp;lt;br/&amp;gt;&#039; released to public domain, August 2006 by Grahame King&amp;lt;br/&amp;gt;a=1&amp;lt;br/&amp;gt;while a&amp;amp;lt;&amp;amp;gt;0&amp;lt;br/&amp;gt;input &amp;amp;quot;test number =&amp;amp;quot;; a&amp;lt;br/&amp;gt;a$ = str$(a)&amp;lt;br/&amp;gt;print &amp;amp;quot;test number as string = &amp;amp;quot;+a$&amp;lt;br/&amp;gt;print &amp;amp;quot;test number in scientific notation = &amp;amp;quot;+ScNotation$(a)&amp;lt;br/&amp;gt;wend&amp;lt;br/&amp;gt;end&amp;lt;br/&amp;gt;function ScNotation$(numin)&amp;lt;br/&amp;gt;&#039; function to express a number as a string in &#039;scientific notation&amp;amp;quot;&amp;lt;br/&amp;gt;if numin = 0 then ScNotation$ = &amp;amp;quot;0&amp;amp;quot; : exit function&amp;lt;br/&amp;gt;&#039; separate number into sign, significant numeric part (mantissa), and exponent&amp;lt;br/&amp;gt;&#039; first extract the sign&amp;lt;br/&amp;gt;absNumIn = abs(numin)&amp;lt;br/&amp;gt;sgnNumIn = absNumIn/numin&amp;lt;br/&amp;gt;if sgnNumIn&amp;amp;gt;0 then&amp;lt;br/&amp;gt;sgnNumIn$ = &amp;amp;quot;&amp;amp;quot;&amp;lt;br/&amp;gt;else&amp;lt;br/&amp;gt;sgnNumIn$ = &amp;amp;quot;-&amp;amp;quot;&amp;lt;br/&amp;gt;end if&amp;lt;br/&amp;gt;&#039; represent unsigned number as a string using str$&amp;lt;br/&amp;gt;absNumIn$ = str$(absNumIn)&amp;lt;br/&amp;gt;&#039; find the &amp;amp;quot;e&amp;amp;quot; in case LB has already put it in a form with an exponent&amp;lt;br/&amp;gt;inde = instr(absNumIn$,&amp;amp;quot;e&amp;amp;quot;)&amp;lt;br/&amp;gt;if inde&amp;amp;gt;0 then&amp;lt;br/&amp;gt;expon = val(mid$(absNumIn$,inde+1))&amp;lt;br/&amp;gt;mantissa$ = mid$(absNumIn$,1,inde-1)&amp;lt;br/&amp;gt;else&amp;lt;br/&amp;gt;expon = 0&amp;lt;br/&amp;gt;mantissa$ = absNumIn$&amp;lt;br/&amp;gt;end if&amp;lt;br/&amp;gt;&#039; move the decimal point in the old mantissa so that there is just one nonzero digit in front of it&amp;lt;br/&amp;gt;&#039; and adjust the exponent accordingly&amp;lt;br/&amp;gt;&#039; start by finding the decimal point and breaking mantissa into its whole part and fractional part&amp;lt;br/&amp;gt;indDot = instr(mantissa$,&amp;amp;quot;.&amp;amp;quot;)&amp;lt;br/&amp;gt;if indDot = 0 then &#039; for integers&amp;lt;br/&amp;gt;indDot = len(mantissa$)&amp;lt;br/&amp;gt;whole$ = mantissa$&amp;lt;br/&amp;gt;fract$ = &amp;amp;quot;&amp;amp;quot;&amp;lt;br/&amp;gt;else&amp;lt;br/&amp;gt;whole$ = mid$(mantissa$,1,indDot-1)&amp;lt;br/&amp;gt;fract$ = mid$(mantissa$,indDot+1)&amp;lt;br/&amp;gt;end if&amp;lt;br/&amp;gt;while val(whole$) &amp;amp;gt; 9 &#039; to move decimal point to the left if necessary&amp;lt;br/&amp;gt;indDot = indDot-1&amp;lt;br/&amp;gt;fract$ = right$(whole$,1)+fract$  &#039; add the last digit from the whole number part to the beginning of fract$&amp;lt;br/&amp;gt;whole$ = left$(whole$,len(whole$)-1)  &#039; and then remove that digit from the whole$&amp;lt;br/&amp;gt;expon = expon+1   &#039; adjust exponent to keep the net result correct&amp;lt;br/&amp;gt;wend&amp;lt;br/&amp;gt;while val(whole$) &amp;amp;lt;= 0 &#039; to move decimal point to the right if necessary&amp;lt;br/&amp;gt;indDot = indDot+1&amp;lt;br/&amp;gt;whole$ = whole$+left$(fract$,1)  &#039; add the first digit of fractional part to the whole number part&amp;lt;br/&amp;gt;fract$ = mid$(fract$,2)   &#039; and then remove that digit from the beginning of the fractional part&amp;lt;br/&amp;gt;expon = expon-1   &#039; adjust exponent to keep the net result correct&amp;lt;br/&amp;gt;wend&amp;lt;br/&amp;gt;&#039; build Scientific Notation string from the three parts - sign, new mantissa and new exponent&amp;lt;br/&amp;gt;ScNotation$ = sgnNumIn$+str$(val(whole$))+&amp;amp;quot;.&amp;amp;quot;+fract$+&amp;amp;quot;e&amp;amp;quot;+str$(expon)&amp;lt;br/&amp;gt;end function&amp;lt;/pre&amp;gt;
 --&gt;
&lt;style type=&quot;text/css&quot;&gt;&lt;!--
/**
 * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
 * (http://qbnz.com/highlighter/ and http://geshi.org/)
 */
.vbnet  {font-family:monospace;}
.vbnet .imp {font-weight: bold; color: red;}
.vbnet .kw1 {color: #0000FF; font-weight: bold;}
.vbnet .kw2 {color: #6a5acd;}
.vbnet .kw3 {color: #6a5acd; font-weight: bold;}
.vbnet .kw4 {color: #cd6a5a;}
.vbnet .kw5 {color: #cd6a5a; font-weight: bold;}
.vbnet .kw7 {color: #000066;}
.vbnet .co1 {color: #008000; font-style: italic;}
.vbnet .coMULTI {color: #008000; font-style: italic;}
.vbnet .es0 {color: #008080; font-weight: bold;}
.vbnet .br0 {color: #000000;}
.vbnet .sy0 {color: #000000;}
.vbnet .st0 {color: #a52a2a; back-color: #fffacd;}
.vbnet .nu0 {color: #a52a2a; back-color: #fffacd;}
.vbnet .me1 {color: #000000;}
.vbnet span.xtra { display:block; }

--&gt;
&lt;/style&gt;&lt;pre class=&quot;vbnet&quot;&gt;&lt;span class=&quot;co1&quot;&gt;&#039; test program for scientific notation function&lt;/span&gt;
&lt;span class=&quot;co1&quot;&gt;&#039; released to public domain, August 2006 by Grahame King&lt;/span&gt;
a&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;while&lt;/span&gt; a&lt;span class=&quot;sy0&quot;&gt;&amp;lt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;
input &lt;span class=&quot;st0&quot;&gt;&amp;quot;test number =&amp;quot;&lt;/span&gt;; a
a$ &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw7&quot;&gt;str$&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;a&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
print &lt;span class=&quot;st0&quot;&gt;&amp;quot;test number as string = &amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;+&lt;/span&gt;a$
print &lt;span class=&quot;st0&quot;&gt;&amp;quot;test number in scientific notation = &amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;+&lt;/span&gt;ScNotation$&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;a&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;wend&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;function&lt;/span&gt; ScNotation$&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;numin&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span class=&quot;co1&quot;&gt;&#039; function to express a number as a string in &#039;scientific notation&amp;quot;&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; numin &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;then&lt;/span&gt; ScNotation$ &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;0&amp;quot;&lt;/span&gt; : &lt;span class=&quot;kw1&quot;&gt;exit&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;function&lt;/span&gt;
&lt;span class=&quot;co1&quot;&gt;&#039; separate number into sign, significant numeric part (mantissa), and exponent&lt;/span&gt;
&lt;span class=&quot;co1&quot;&gt;&#039; first extract the sign&lt;/span&gt;
absNumIn &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw7&quot;&gt;abs&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;numin&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
sgnNumIn &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; absNumIn&lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;numin
&lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; sgnNumIn&lt;span class=&quot;sy0&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;then&lt;/span&gt;
sgnNumIn$ &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt;
sgnNumIn$ &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;-&amp;quot;&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt;
&lt;span class=&quot;co1&quot;&gt;&#039; represent unsigned number as a string using str$&lt;/span&gt;
absNumIn$ &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw7&quot;&gt;str$&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;absNumIn&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span class=&quot;co1&quot;&gt;&#039; find the &amp;quot;e&amp;quot; in case LB has already put it in a form with an exponent&lt;/span&gt;
inde &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw7&quot;&gt;instr&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;absNumIn$,&lt;span class=&quot;st0&quot;&gt;&amp;quot;e&amp;quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; inde&lt;span class=&quot;sy0&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;then&lt;/span&gt;
expon &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw7&quot;&gt;val&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw7&quot;&gt;mid$&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;absNumIn$,inde&lt;span class=&quot;sy0&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
mantissa$ &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw7&quot;&gt;mid$&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;absNumIn$,&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;,inde&lt;span class=&quot;sy0&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt;
expon &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;
mantissa$ &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; absNumIn$
&lt;span class=&quot;kw1&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt;
&lt;span class=&quot;co1&quot;&gt;&#039; move the decimal point in the old mantissa so that there is just one nonzero digit in front of it&lt;/span&gt;
&lt;span class=&quot;co1&quot;&gt;&#039; and adjust the exponent accordingly&lt;/span&gt;
&lt;span class=&quot;co1&quot;&gt;&#039; start by finding the decimal point and breaking mantissa into its whole part and fractional part&lt;/span&gt;
indDot &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw7&quot;&gt;instr&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;mantissa$,&lt;span class=&quot;st0&quot;&gt;&amp;quot;.&amp;quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; indDot &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;co1&quot;&gt;&#039; for integers&lt;/span&gt;
indDot &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; len&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;mantissa$&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
whole$ &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; mantissa$
fract$ &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt;
whole$ &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw7&quot;&gt;mid$&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;mantissa$,&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;,indDot&lt;span class=&quot;sy0&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
fract$ &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw7&quot;&gt;mid$&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;mantissa$,indDot&lt;span class=&quot;sy0&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;kw7&quot;&gt;val&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;whole$&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;9&lt;/span&gt; &lt;span class=&quot;co1&quot;&gt;&#039; to move decimal point to the left if necessary&lt;/span&gt;
indDot &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; indDot&lt;span class=&quot;sy0&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;
fract$ &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw7&quot;&gt;right$&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;whole$,&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;+&lt;/span&gt;fract$  &lt;span class=&quot;co1&quot;&gt;&#039; add the last digit from the whole number part to the beginning of fract$&lt;/span&gt;
whole$ &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw7&quot;&gt;left$&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;whole$,len&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;whole$&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;  &lt;span class=&quot;co1&quot;&gt;&#039; and then remove that digit from the whole$&lt;/span&gt;
expon &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; expon&lt;span class=&quot;sy0&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;   &lt;span class=&quot;co1&quot;&gt;&#039; adjust exponent to keep the net result correct&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;wend&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;kw7&quot;&gt;val&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;whole$&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;co1&quot;&gt;&#039; to move decimal point to the right if necessary&lt;/span&gt;
indDot &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; indDot&lt;span class=&quot;sy0&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;
whole$ &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; whole$&lt;span class=&quot;sy0&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;kw7&quot;&gt;left$&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;fract$,&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;  &lt;span class=&quot;co1&quot;&gt;&#039; add the first digit of fractional part to the whole number part&lt;/span&gt;
fract$ &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw7&quot;&gt;mid$&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;fract$,&lt;span class=&quot;nu0&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;   &lt;span class=&quot;co1&quot;&gt;&#039; and then remove that digit from the beginning of the fractional part&lt;/span&gt;
expon &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; expon&lt;span class=&quot;sy0&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;   &lt;span class=&quot;co1&quot;&gt;&#039; adjust exponent to keep the net result correct&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;wend&lt;/span&gt;
&lt;span class=&quot;co1&quot;&gt;&#039; build Scientific Notation string from the three parts - sign, new mantissa and new exponent&lt;/span&gt;
ScNotation$ &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; sgnNumIn$&lt;span class=&quot;sy0&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;kw7&quot;&gt;str$&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw7&quot;&gt;val&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;whole$&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;.&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;+&lt;/span&gt;fract$&lt;span class=&quot;sy0&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;e&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;kw7&quot;&gt;str$&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;expon&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;function&lt;/span&gt;&lt;/pre&gt;

&lt;!-- ws:end:WikiTextCodeRule:4 --&gt;&lt;br /&gt;
&lt;!-- ws:start:WikiTextHeadingRule:16:&amp;lt;h2&amp;gt; --&gt;&lt;h2 id=&quot;toc5&quot;&gt;&lt;a name=&quot;Precision and Scientific Notation in Liberty BASIC-General Rounding Function&quot;&gt;&lt;/a&gt;&lt;!-- ws:end:WikiTextHeadingRule:16 --&gt;General Rounding Function&lt;/h2&gt;
&lt;br /&gt;
The following LB function will round any number (positive or negative) to any number of places. For run-of-the-mill accounting applications, simple rounding to two decimals with the USING function should do.&lt;br /&gt;
&lt;br /&gt;
&lt;!-- ws:start:WikiTextCodeRule:5:
&amp;lt;pre class=&amp;quot;vbnet&amp;quot;&amp;gt;&#039; demo of rounding with over-USING, reasonable USING and the round() function below:&amp;lt;br/&amp;gt;num = 77725.214 +0.0005&amp;lt;br/&amp;gt;print num, &amp;amp;quot;from print num, with no formatting in print statement&amp;amp;quot;&amp;lt;br/&amp;gt;print&amp;lt;br/&amp;gt;print &amp;amp;quot;The next three lines with the using function show what over-precision does.&amp;amp;quot;&amp;lt;br/&amp;gt;print &amp;amp;quot;77725.214 = &amp;amp;quot;, using(&amp;amp;quot;#####.#################&amp;amp;quot;,77725.214)&amp;lt;br/&amp;gt;print &amp;amp;quot; 0.0005 = &amp;amp;quot;, using(&amp;amp;quot;#####.#################&amp;amp;quot;,0.0005)&amp;lt;br/&amp;gt;print &amp;amp;quot;77725.214 +0.0005 = &amp;amp;quot;, using(&amp;amp;quot;#####.#################&amp;amp;quot;,num)&amp;lt;br/&amp;gt;print&amp;lt;br/&amp;gt;print &amp;amp;quot;Precision within double-precision bounds removes the wierdness:&amp;amp;quot;&amp;lt;br/&amp;gt;print &amp;amp;quot;77725.214 = &amp;amp;quot;, using(&amp;amp;quot;#####.########&amp;amp;quot;,77725.214)&amp;lt;br/&amp;gt;print &amp;amp;quot; 0.0005 = &amp;amp;quot;, using(&amp;amp;quot;#####.########&amp;amp;quot;,0.0005)&amp;lt;br/&amp;gt;print &amp;amp;quot;77725.214 +0.0005 = &amp;amp;quot;, using(&amp;amp;quot;#####.########&amp;amp;quot;,num)&amp;lt;br/&amp;gt;print&amp;lt;br/&amp;gt;print &amp;amp;quot;Using the mathematical rounding function:-&amp;amp;quot;&amp;lt;br/&amp;gt;print &amp;amp;quot;Rounding to 4 decimals, 3 decimals ...., and finally to the nearest thousand: &amp;amp;quot;&amp;lt;br/&amp;gt;for i = -4 to 3&amp;lt;br/&amp;gt;print using(&amp;amp;quot;##&amp;amp;quot;,i); &amp;amp;quot; ... &amp;amp;quot;; round(num,i)&amp;lt;br/&amp;gt;next&amp;lt;br/&amp;gt;end&amp;lt;br/&amp;gt;function round(x,places)&amp;lt;br/&amp;gt;&#039;positive &amp;amp;quot;places&amp;amp;quot; rounds to whole number places,&amp;lt;br/&amp;gt;&#039;negative &amp;amp;quot;places&amp;amp;quot; rounds to fractional places&amp;lt;br/&amp;gt;round = sgn(x)*int((abs(x)*10^(-1*places))+0.5)*(10^places)&amp;lt;br/&amp;gt;end function &#039;round&amp;lt;br/&amp;gt;function sgn(x)&amp;lt;br/&amp;gt;if x&amp;amp;lt;0 then&amp;lt;br/&amp;gt;sgn = -1&amp;lt;br/&amp;gt;else&amp;lt;br/&amp;gt;sgn = 1&amp;lt;br/&amp;gt;end if&amp;lt;br/&amp;gt;end function &#039;sgn&amp;lt;/pre&amp;gt;
 --&gt;
&lt;style type=&quot;text/css&quot;&gt;&lt;!--
/**
 * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
 * (http://qbnz.com/highlighter/ and http://geshi.org/)
 */
.vbnet  {font-family:monospace;}
.vbnet .imp {font-weight: bold; color: red;}
.vbnet .kw1 {color: #0000FF; font-weight: bold;}
.vbnet .kw2 {color: #6a5acd;}
.vbnet .kw3 {color: #6a5acd; font-weight: bold;}
.vbnet .kw4 {color: #cd6a5a;}
.vbnet .kw5 {color: #cd6a5a; font-weight: bold;}
.vbnet .kw7 {color: #000066;}
.vbnet .co1 {color: #008000; font-style: italic;}
.vbnet .coMULTI {color: #008000; font-style: italic;}
.vbnet .es0 {color: #008080; font-weight: bold;}
.vbnet .br0 {color: #000000;}
.vbnet .sy0 {color: #000000;}
.vbnet .st0 {color: #a52a2a; back-color: #fffacd;}
.vbnet .nu0 {color: #a52a2a; back-color: #fffacd;}
.vbnet .me1 {color: #000000;}
.vbnet span.xtra { display:block; }

--&gt;
&lt;/style&gt;&lt;pre class=&quot;vbnet&quot;&gt;&lt;span class=&quot;co1&quot;&gt;&#039; demo of rounding with over-USING, reasonable USING and the round() function below:&lt;/span&gt;
num &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;77725.214&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0.0005&lt;/span&gt;
print num, &lt;span class=&quot;st0&quot;&gt;&amp;quot;from print num, with no formatting in print statement&amp;quot;&lt;/span&gt;
print
print &lt;span class=&quot;st0&quot;&gt;&amp;quot;The next three lines with the using function show what over-precision does.&amp;quot;&lt;/span&gt;
print &lt;span class=&quot;st0&quot;&gt;&amp;quot;77725.214 = &amp;quot;&lt;/span&gt;, &lt;span class=&quot;kw1&quot;&gt;using&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;#####.#################&amp;quot;&lt;/span&gt;,&lt;span class=&quot;nu0&quot;&gt;77725.214&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
print &lt;span class=&quot;st0&quot;&gt;&amp;quot; 0.0005 = &amp;quot;&lt;/span&gt;, &lt;span class=&quot;kw1&quot;&gt;using&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;#####.#################&amp;quot;&lt;/span&gt;,&lt;span class=&quot;nu0&quot;&gt;0.0005&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
print &lt;span class=&quot;st0&quot;&gt;&amp;quot;77725.214 +0.0005 = &amp;quot;&lt;/span&gt;, &lt;span class=&quot;kw1&quot;&gt;using&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;#####.#################&amp;quot;&lt;/span&gt;,num&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
print
print &lt;span class=&quot;st0&quot;&gt;&amp;quot;Precision within double-precision bounds removes the wierdness:&amp;quot;&lt;/span&gt;
print &lt;span class=&quot;st0&quot;&gt;&amp;quot;77725.214 = &amp;quot;&lt;/span&gt;, &lt;span class=&quot;kw1&quot;&gt;using&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;#####.########&amp;quot;&lt;/span&gt;,&lt;span class=&quot;nu0&quot;&gt;77725.214&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
print &lt;span class=&quot;st0&quot;&gt;&amp;quot; 0.0005 = &amp;quot;&lt;/span&gt;, &lt;span class=&quot;kw1&quot;&gt;using&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;#####.########&amp;quot;&lt;/span&gt;,&lt;span class=&quot;nu0&quot;&gt;0.0005&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
print &lt;span class=&quot;st0&quot;&gt;&amp;quot;77725.214 +0.0005 = &amp;quot;&lt;/span&gt;, &lt;span class=&quot;kw1&quot;&gt;using&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;#####.########&amp;quot;&lt;/span&gt;,num&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
print
print &lt;span class=&quot;st0&quot;&gt;&amp;quot;Using the mathematical rounding function:-&amp;quot;&lt;/span&gt;
print &lt;span class=&quot;st0&quot;&gt;&amp;quot;Rounding to 4 decimals, 3 decimals ...., and finally to the nearest thousand: &amp;quot;&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;for&lt;/span&gt; i &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;4&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;to&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;3&lt;/span&gt;
print &lt;span class=&quot;kw1&quot;&gt;using&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;##&amp;quot;&lt;/span&gt;,i&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;span class=&quot;st0&quot;&gt;&amp;quot; ... &amp;quot;&lt;/span&gt;; round&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;num,i&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;next&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;function&lt;/span&gt; round&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;x,places&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span class=&quot;co1&quot;&gt;&#039;positive &amp;quot;places&amp;quot; rounds to whole number places,&lt;/span&gt;
&lt;span class=&quot;co1&quot;&gt;&#039;negative &amp;quot;places&amp;quot; rounds to fractional places&lt;/span&gt;
round &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; sgn&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;x&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;kw7&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw7&quot;&gt;abs&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;x&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;^&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt;places&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0.5&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;^&lt;/span&gt;places&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;co1&quot;&gt;&#039;round&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;function&lt;/span&gt; sgn&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;x&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; x&lt;span class=&quot;sy0&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;then&lt;/span&gt;
sgn &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt;
sgn &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;co1&quot;&gt;&#039;sgn&lt;/span&gt;&lt;/pre&gt;

&lt;!-- ws:end:WikiTextCodeRule:5 --&gt;&lt;br /&gt;
&lt;!-- ws:start:WikiTextHeadingRule:18:&amp;lt;h2&amp;gt; --&gt;&lt;h2 id=&quot;toc6&quot;&gt;&lt;a name=&quot;Precision and Scientific Notation in Liberty BASIC-What&#039;s Wrong with Using USING() for Rounding?&quot;&gt;&lt;/a&gt;&lt;!-- ws:end:WikiTextHeadingRule:18 --&gt;What&#039;s Wrong with Using USING() for Rounding?&lt;/h2&gt;
&lt;br /&gt;
Nothing most of the time. The main advantage of the mathematical form is that it easily handles variable precision. Suppose you want to vary the number of decimal places in your output depending on the results of a set of calculations without knowing before hand what format will be required. This is messy to do with the using() function particularly if you can&#039;t predict where the decimal point might be.&lt;br /&gt;
&lt;br /&gt;
&lt;!-- ws:start:WikiTextHeadingRule:20:&amp;lt;h2&amp;gt; --&gt;&lt;h2 id=&quot;toc7&quot;&gt;&lt;a name=&quot;Precision and Scientific Notation in Liberty BASIC-Beyond Double Precision&quot;&gt;&lt;/a&gt;&lt;!-- ws:end:WikiTextHeadingRule:20 --&gt;Beyond Double Precision&lt;/h2&gt;
&lt;br /&gt;
Finally, if you&#039;re thinking of doing calculations which will produce results smaller than say about 1.0e-10, you will need to be very mathematically savvy in how you go about it. I imagine only scientists and pure mathematicians might be interested in doing this and they would need to know where to learn about techniques for ensuring accurate results. Remember that 1.0e-8 squared is 0 to double precision, so if you are evaluating expressions containing squares and cubes etc, your results can quickly become hopelessly inaccurate as the input numbers become smaller.&lt;br /&gt;
&lt;hr /&gt;
&lt;!-- ws:start:WikiTextTocRule:32:&amp;lt;img id=&amp;quot;wikitext@@toc@@normal&amp;quot; class=&amp;quot;WikiMedia WikiMediaToc&amp;quot; title=&amp;quot;Table of Contents&amp;quot; src=&amp;quot;/site/embedthumbnail/toc/normal?w=225&amp;amp;h=100&amp;quot;/&amp;gt; --&gt;&lt;div id=&quot;toc&quot;&gt;&lt;h1 class=&quot;nopad&quot;&gt;Table of Contents&lt;/h1&gt;&lt;!-- ws:end:WikiTextTocRule:32 --&gt;&lt;!-- ws:start:WikiTextTocRule:33: --&gt;&lt;div style=&quot;margin-left: 1em;&quot;&gt;&lt;a href=&quot;#Precision and Scientific Notation in Liberty BASIC&quot;&gt;Precision and Scientific Notation in Liberty BASIC&lt;/a&gt;&lt;/div&gt;
&lt;!-- ws:end:WikiTextTocRule:33 --&gt;&lt;!-- ws:start:WikiTextTocRule:34: --&gt;&lt;div style=&quot;margin-left: 2em;&quot;&gt;&lt;a href=&quot;#Precision and Scientific Notation in Liberty BASIC-Precision and Rounding&quot;&gt;Precision and Rounding&lt;/a&gt;&lt;/div&gt;
&lt;!-- ws:end:WikiTextTocRule:34 --&gt;&lt;!-- ws:start:WikiTextTocRule:35: --&gt;&lt;div style=&quot;margin-left: 2em;&quot;&gt;&lt;a href=&quot;#Precision and Scientific Notation in Liberty BASIC-Precision and Accuracy&quot;&gt;Precision and Accuracy&lt;/a&gt;&lt;/div&gt;
&lt;!-- ws:end:WikiTextTocRule:35 --&gt;&lt;!-- ws:start:WikiTextTocRule:36: --&gt;&lt;div style=&quot;margin-left: 2em;&quot;&gt;&lt;a href=&quot;#Precision and Scientific Notation in Liberty BASIC-Scientific Notation&quot;&gt;Scientific Notation&lt;/a&gt;&lt;/div&gt;
&lt;!-- ws:end:WikiTextTocRule:36 --&gt;&lt;!-- ws:start:WikiTextTocRule:37: --&gt;&lt;div style=&quot;margin-left: 2em;&quot;&gt;&lt;a href=&quot;#Precision and Scientific Notation in Liberty BASIC-General Function for Scientific Notation&quot;&gt;General Function for Scientific Notation&lt;/a&gt;&lt;/div&gt;
&lt;!-- ws:end:WikiTextTocRule:37 --&gt;&lt;!-- ws:start:WikiTextTocRule:38: --&gt;&lt;div style=&quot;margin-left: 2em;&quot;&gt;&lt;a href=&quot;#Precision and Scientific Notation in Liberty BASIC-General Rounding Function&quot;&gt;General Rounding Function&lt;/a&gt;&lt;/div&gt;
&lt;!-- ws:end:WikiTextTocRule:38 --&gt;&lt;!-- ws:start:WikiTextTocRule:39: --&gt;&lt;div style=&quot;margin-left: 2em;&quot;&gt;&lt;a href=&quot;#Precision and Scientific Notation in Liberty BASIC-What&#039;s Wrong with Using USING() for Rounding?&quot;&gt;What&#039;s Wrong with Using USING() for Rounding?&lt;/a&gt;&lt;/div&gt;
&lt;!-- ws:end:WikiTextTocRule:39 --&gt;&lt;!-- ws:start:WikiTextTocRule:40: --&gt;&lt;div style=&quot;margin-left: 2em;&quot;&gt;&lt;a href=&quot;#Precision and Scientific Notation in Liberty BASIC-Beyond Double Precision&quot;&gt;Beyond Double Precision&lt;/a&gt;&lt;/div&gt;
&lt;!-- ws:end:WikiTextTocRule:40 --&gt;&lt;!-- ws:start:WikiTextTocRule:41: --&gt;&lt;/div&gt;
&lt;!-- ws:end:WikiTextTocRule:41 --&gt;</description>
          </item>

  </channel>
</rss>