<?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[Doubele in Bruch konvergieren Matheproblem: (Kettenbruchentwicklung)]]></title><description><![CDATA[<p>Hallo liebe Leute!</p>
<p>Leider bin ich auch nicht nach vielen Versuchen und mehrmaligen ausprobieren auf den Fehler in meiner Klasse gekommen. Dieses Problem ist ein mathematisches.<br />
Ich habe Eine Klasse geschrieben die mit Brüchen rechnet und auch doubles in Brüche konvergieren soll aber leider bekomme ich nur Müll wenn ich die Kettenbruchentwicklung anwenden will.</p>
<p>Ich poste den relevanten Konstruktor und auf Nachfrage gerne auch die ganze Klasse. Ich hoffe Ihr könnt mir helfen.</p>
<p>Standardkonstruktor:</p>
<pre><code class="language-cpp">Fraction::Fraction(long Zaehler, long Nenner) throw (Fraction::DivisionByZero);
</code></pre>
<p>Hier der double Konstruktor:</p>
<pre><code class="language-cpp">Fraction::Fraction(double a) throw (Fraction::domain_error)
{
/////Errorhandling ist noch nicht implementiert!

	const short aprox=10;
	long vec[aprox],i=1;
	Fraction temp;

	//Kettenbruchentwicklung:
	vec[0]=floor(a);

	a-=floor(a);
	while(i&lt;aprox &amp;&amp; floor(a*1000.0)!=0.0)
	{
		a=pow(a,-1.0);
		vec[i]=floor(a);
		a-=floor(a);
		i++;
	}
//Kettenbruchentwicklung_Ende

	if(i&gt;1)
	{
//////////////////PROBLEMATISCHER_TEIL//////////////////////////
		temp=Fraction(vec[i-1],1L)+Fraction(1L,vec[i]);
		i-=2;
		while (i&gt;0)
		{
			temp=Fraction(vec[i],1L)+Fraction(1L,1L)/temp;
			--i;
		}
		nenner=temp.nenner;zaehler=temp.zaehler;
//////////////////PROBLEMATISCHER_TEIL_ENDE/////////////////////
	}
	else {zaehler=vec[0]; nenner=1;}

}
</code></pre>
<p>Es ist wahrscheinlich nur ein Denkfehler.<br />
Danke schon mal im voraus.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/305632/doubele-in-bruch-konvergieren-matheproblem-kettenbruchentwicklung</link><generator>RSS for Node</generator><lastBuildDate>Sat, 08 Aug 2026 19:02:50 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/305632.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 04 Jul 2012 01:14:57 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Doubele in Bruch konvergieren Matheproblem: (Kettenbruchentwicklung) on Wed, 04 Jul 2012 02:29:11 GMT]]></title><description><![CDATA[<p>Hallo liebe Leute!</p>
<p>Leider bin ich auch nicht nach vielen Versuchen und mehrmaligen ausprobieren auf den Fehler in meiner Klasse gekommen. Dieses Problem ist ein mathematisches.<br />
Ich habe Eine Klasse geschrieben die mit Brüchen rechnet und auch doubles in Brüche konvergieren soll aber leider bekomme ich nur Müll wenn ich die Kettenbruchentwicklung anwenden will.</p>
<p>Ich poste den relevanten Konstruktor und auf Nachfrage gerne auch die ganze Klasse. Ich hoffe Ihr könnt mir helfen.</p>
<p>Standardkonstruktor:</p>
<pre><code class="language-cpp">Fraction::Fraction(long Zaehler, long Nenner) throw (Fraction::DivisionByZero);
</code></pre>
<p>Hier der double Konstruktor:</p>
<pre><code class="language-cpp">Fraction::Fraction(double a) throw (Fraction::domain_error)
{
/////Errorhandling ist noch nicht implementiert!

	const short aprox=10;
	long vec[aprox],i=1;
	Fraction temp;

	//Kettenbruchentwicklung:
	vec[0]=floor(a);

	a-=floor(a);
	while(i&lt;aprox &amp;&amp; floor(a*1000.0)!=0.0)
	{
		a=pow(a,-1.0);
		vec[i]=floor(a);
		a-=floor(a);
		i++;
	}
//Kettenbruchentwicklung_Ende

	if(i&gt;1)
	{
//////////////////PROBLEMATISCHER_TEIL//////////////////////////
		temp=Fraction(vec[i-1],1L)+Fraction(1L,vec[i]);
		i-=2;
		while (i&gt;0)
		{
			temp=Fraction(vec[i],1L)+Fraction(1L,1L)/temp;
			--i;
		}
		nenner=temp.nenner;zaehler=temp.zaehler;
//////////////////PROBLEMATISCHER_TEIL_ENDE/////////////////////
	}
	else {zaehler=vec[0]; nenner=1;}

}
</code></pre>
<p>Es ist wahrscheinlich nur ein Denkfehler.<br />
Danke schon mal im voraus.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2229852</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2229852</guid><dc:creator><![CDATA[Markuhn]]></dc:creator><pubDate>Wed, 04 Jul 2012 02:29:11 GMT</pubDate></item><item><title><![CDATA[Reply to Doubele in Bruch konvergieren Matheproblem: (Kettenbruchentwicklung) on Wed, 04 Jul 2012 05:52:12 GMT]]></title><description><![CDATA[<p>Markuhn schrieb:</p>
<blockquote>
<pre><code class="language-cpp">//////////////////PROBLEMATISCHER_TEIL//////////////////////////
		temp=Fraction(vec[i-1],1L)+Fraction(1L,vec[i]);
</code></pre>
</blockquote>
<p>vec[i] ist hier uninitialisiert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2229859</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2229859</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Wed, 04 Jul 2012 05:52:12 GMT</pubDate></item><item><title><![CDATA[Reply to Doubele in Bruch konvergieren Matheproblem: (Kettenbruchentwicklung) on Wed, 04 Jul 2012 07:19:37 GMT]]></title><description><![CDATA[<p>Hallo Markuhn,</p>
<p>Willkommen im C++-Forum.</p>
<p>Zu diesem Thema hatte ich bereits 2007 einen Beitrag verfasst (s. <a href="http://www.c-plusplus.net/forum/p1411302#1411302" rel="nofollow">Gleitkommazahl in Bruch</a>).<br />
Zu Deinem speziellen Problem: s.Antwort von MFK.</p>
<p>Gruß<br />
Werner</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2229870</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2229870</guid><dc:creator><![CDATA[Werner Salomon]]></dc:creator><pubDate>Wed, 04 Jul 2012 07:19:37 GMT</pubDate></item><item><title><![CDATA[Reply to Doubele in Bruch konvergieren Matheproblem: (Kettenbruchentwicklung) on Wed, 04 Jul 2012 09:48:54 GMT]]></title><description><![CDATA[<p>Danke für die schnellen Antworten. Jetzt funktioniert es so wie ich möchte. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/7393">@Werner</a>: Dein Link ist Hammer aber ich muss mir erst die Zeit nehmen den durch zuarbeiten <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<p>Liebe Grüße,<br />
Markuhn.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2229943</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2229943</guid><dc:creator><![CDATA[Markuhn]]></dc:creator><pubDate>Wed, 04 Jul 2012 09:48:54 GMT</pubDate></item></channel></rss>