<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    The nearest double-precision IEEE-754 binary floating-point number
    for the decimal number PI <br>
     <br>
    3.141592653589793 23846264338327950288419716939937510582097494459230
    78164 06286 ....<br>
     <br>
    is<br>
    <p>3.141592653589793 115997963468544185161590576171875</p>
    <p>It can be shown this way: its internal base 2 representation is
      (I added spaces to separate the sign, exponent and mantissa) is
      given in Scilab by<br>
    </p>
    <p>--> bitstring(%pi)<br>
       ans  =<br>
      <br>
        "0 10000000000
      1001001000011111101101010100010001000010110100011000"</p>
    <p>i.e. a positive number, with exponent 2^(1024-1023) = 1 and
      mantissa<br>
    </p>
    <p>1.1001001000011111101101010100010001000010110100011000</p>
    <p>i.e. the leading "1."  is implicit (normalized convention) and
      has to be added. Hence, the final numer, after mutiplication by
      2^exponent, is</p>
    <p>11.001001000011111101101010100010001000010110100011000</p>
    <p>You won't be able to convert this back to decimal by using
      floating point arithmetic. There is an efficient converter at 
      <a class="moz-txt-link-freetext" href="https://www.exploringbinary.com/binary-converter/">https://www.exploringbinary.com/binary-converter/</a> which gives the
      actual result<br>
    </p>
    <img moz-do-not-send="false"
      src="cid:part1.701961A8.282A0C71@utc.fr" alt="convert" width="699"
      height="214">
    <p><br>
    </p>
    <p>S.<br>
    </p>
    <div class="moz-cite-prefix">Le 08/01/2021 à 10:48, Jean-Yves
      Baudais a écrit :<br>
    </div>
    <blockquote type="cite"
      cite="mid:519909984.282175.1610099311730.JavaMail.zimbra@insa-rennes.fr">
      <pre class="moz-quote-pre" wrap="">Hello,

----- Original Message -----
</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">The function could be sinpi() or similar, with two arguments: the main
argument x and an integer argument n, being its result equivalent to

sin(x - n*pi)
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">
So now the problem can be how these large numbers are obtained
--> a=1e16+1
--> a-1e16
of course equals zero. 

</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">where pi is the exact value of pi
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">
Hum... What does "exact" mean in numerical calculus? (In symbolic one, it's simpler :-)

--> format(25)
--> %pi
3.141592653589793115998

the 6 last digits are wrong (cf. <a class="moz-txt-link-freetext" href="https://antispam.utc.fr/proxy/2/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/oeis.org/A000796">https://antispam.utc.fr/proxy/2/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/oeis.org/A000796</a>) because of float64 format.

</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">Probably it is not proper to refer to it as noise, since the difference
is deterministic as can be demonstrated by using the function nearfloat()
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">
Maybe noise is not the right word. But, the difference is fixed and %pi give all the time the same digit in format(25). It's a bit weird (up to my ignorance) to have these wrong deterministic digits... Hum, maybe I need to read "What Every Computer Scientist Should Know about Floating-Point Arithmetic", David Goldberg, ACM Computing Surveys, vol. 23, no  1, mars 1991 recommanded by <a class="moz-txt-link-freetext" href="https://antispam.utc.fr/proxy/2/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/en.wikipedia.org/wiki/IEEE_754">https://antispam.utc.fr/proxy/2/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/en.wikipedia.org/wiki/IEEE_754</a>

--Jean-Yves

_______________________________________________
users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:users@lists.scilab.org">users@lists.scilab.org</a>
<a class="moz-txt-link-freetext" href="https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users">https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users</a>
</pre>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
<a class="moz-txt-link-freetext" href="http://www.utc.fr/~mottelet">http://www.utc.fr/~mottelet</a>
</pre>
  </body>
</html>