<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Signifikante Stellen rausfinden]]></title><description><![CDATA[<p>Hallo zusammen</p>
<p>Ich frag mich grade, wie ich bei der Berechnung der Eulerschen Zahl e die Anzahl korrekter Stellen rausfinden kann.<br />
Hab schon ein bisschen Code</p>
<pre><code class="language-cpp">double e = 0;
int nth = 1;
int n = Benutzereingabe;
//
for( int i = 0; i &lt; n; ++i ) {
        e = pow( ( 1.0 + 1.0/i ), 1.0*i );
        cout &lt;&lt; &quot;n: &quot; &lt;&lt; i &lt;&lt; &quot; e: &quot; &lt;&lt; e &lt;&lt; endl;
        if( nth == 1 &amp;&amp; e &gt;= 2.7 &amp;&amp; e &lt; 2.8 ) {
            print_results( i, nth, e, );
            nth++;
        }
        if( nth == 2 &amp;&amp; e &gt;= 2.71 &amp;&amp; e &lt; 2.72 ) {
            print_results( i, nth, e, );
            nth++;
        }
        if( nth == 3 &amp;&amp; e &gt;= 2.718 &amp;&amp; e &lt; 2.719 ) {
            print_results( i, nth, e, );
            nth++;
        }
}
</code></pre>
<p>Aber das ist mir zuviel redundanz, wenn ich bis auf 12 oder 16 erweitern will. Kann ich die n-te Stelle nicht anders Prüfen?<br />
2. Frage wäre, wie kann ich mehr als 16 Stellen prüfen, ohne grosse Datentypen nicht oder? Wie berechneten sie zB Pi auf 200 Kommastellen?</p>
<p>Vielen Dank schonmal im voraus.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/164771/signifikante-stellen-rausfinden</link><generator>RSS for Node</generator><lastBuildDate>Mon, 14 Sep 2026 02:10:22 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/164771.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 12 Nov 2006 15:32:09 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Signifikante Stellen rausfinden on Sun, 12 Nov 2006 15:32:09 GMT]]></title><description><![CDATA[<p>Hallo zusammen</p>
<p>Ich frag mich grade, wie ich bei der Berechnung der Eulerschen Zahl e die Anzahl korrekter Stellen rausfinden kann.<br />
Hab schon ein bisschen Code</p>
<pre><code class="language-cpp">double e = 0;
int nth = 1;
int n = Benutzereingabe;
//
for( int i = 0; i &lt; n; ++i ) {
        e = pow( ( 1.0 + 1.0/i ), 1.0*i );
        cout &lt;&lt; &quot;n: &quot; &lt;&lt; i &lt;&lt; &quot; e: &quot; &lt;&lt; e &lt;&lt; endl;
        if( nth == 1 &amp;&amp; e &gt;= 2.7 &amp;&amp; e &lt; 2.8 ) {
            print_results( i, nth, e, );
            nth++;
        }
        if( nth == 2 &amp;&amp; e &gt;= 2.71 &amp;&amp; e &lt; 2.72 ) {
            print_results( i, nth, e, );
            nth++;
        }
        if( nth == 3 &amp;&amp; e &gt;= 2.718 &amp;&amp; e &lt; 2.719 ) {
            print_results( i, nth, e, );
            nth++;
        }
}
</code></pre>
<p>Aber das ist mir zuviel redundanz, wenn ich bis auf 12 oder 16 erweitern will. Kann ich die n-te Stelle nicht anders Prüfen?<br />
2. Frage wäre, wie kann ich mehr als 16 Stellen prüfen, ohne grosse Datentypen nicht oder? Wie berechneten sie zB Pi auf 200 Kommastellen?</p>
<p>Vielen Dank schonmal im voraus.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1173069</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1173069</guid><dc:creator><![CDATA[Simon&amp;amp;Simon]]></dc:creator><pubDate>Sun, 12 Nov 2006 15:32:09 GMT</pubDate></item><item><title><![CDATA[Reply to Signifikante Stellen rausfinden on Mon, 13 Nov 2006 08:03:10 GMT]]></title><description><![CDATA[<p>Erstens: Pack das ganze doch in eine Schleife (und such dir eine Rundungsfunktion, um aus dem &quot;exakten&quot; Wert die notwendigen Stellen abzuschneiden):</p>
<pre><code class="language-cpp">double round_down(double val,int digits)
{
  double ex = pow(10,digits);
  return (int)(val*ex) / ex;
}

double round_up(double val,int digits)
{
  double ex = pow(10,digits);
  return (int)(val*ex+1) / ex;
}//geht sicher eleganter

if((e &gt;= round_down(exp(1),-nth)) &amp;&amp; (e &lt; round_up(exp(1),-nth)
  print_results(i,nth++,e);
</code></pre>
<p>Zweitens: Um über die Genauigkeit von long double hinauszugehen, brauchst du eine Spezialbibliothek (wieso komme ich jetzt auf &quot;GMP&quot;?)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1173378</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1173378</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 13 Nov 2006 08:03:10 GMT</pubDate></item></channel></rss>