<?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[größte double die kleiner als x ist]]></title><description><![CDATA[<p>Ich brauche in meinem Jump'n Run Spiel eine Funktion die von einem vorhandenen double x den größten double herausfindet im Bereich von -unendlich bis &lt;x. Auch brauche ich eine Funktion die von einem vorhandenen double x den kleinsten double herausfindet im Bereich von +unendlich bis &gt;x.</p>
<p>NACHTRAG: Das Problem dabei ist, dass ich dynamisch zur compilierzeit herausfinden muss wie viele Nachkommastellen ein double verträgt und jenachdem -0.000000000000000001 oder -0.0000000000000001 hinzuaddieren muss.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/304224/größte-double-die-kleiner-als-x-ist</link><generator>RSS for Node</generator><lastBuildDate>Mon, 10 Aug 2026 00:49:41 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/304224.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 01 Jun 2012 09:42:37 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to größte double die kleiner als x ist on Fri, 01 Jun 2012 09:47:54 GMT]]></title><description><![CDATA[<p>Ich brauche in meinem Jump'n Run Spiel eine Funktion die von einem vorhandenen double x den größten double herausfindet im Bereich von -unendlich bis &lt;x. Auch brauche ich eine Funktion die von einem vorhandenen double x den kleinsten double herausfindet im Bereich von +unendlich bis &gt;x.</p>
<p>NACHTRAG: Das Problem dabei ist, dass ich dynamisch zur compilierzeit herausfinden muss wie viele Nachkommastellen ein double verträgt und jenachdem -0.000000000000000001 oder -0.0000000000000001 hinzuaddieren muss.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2218062</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2218062</guid><dc:creator><![CDATA[tupolew.eljam]]></dc:creator><pubDate>Fri, 01 Jun 2012 09:47:54 GMT</pubDate></item><item><title><![CDATA[Reply to größte double die kleiner als x ist on Fri, 01 Jun 2012 09:53:34 GMT]]></title><description><![CDATA[<p><code>numeric_limits&lt; double &gt;::epsilon()</code></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2218067</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2218067</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Fri, 01 Jun 2012 09:53:34 GMT</pubDate></item><item><title><![CDATA[Reply to größte double die kleiner als x ist on Fri, 01 Jun 2012 09:54:26 GMT]]></title><description><![CDATA[<p>Wie definierst du unendlich?</p>
<p>Ich versteh dich nicht ganz: der größte double zwischen -&quot;unendlich&quot; und &lt;=x == x<br />
<img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
<p>Oder verstehe ich dich da falsch??</p>
<p>gruß<br />
syntax</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2218068</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2218068</guid><dc:creator><![CDATA[Syntax_error]]></dc:creator><pubDate>Fri, 01 Jun 2012 09:54:26 GMT</pubDate></item><item><title><![CDATA[Reply to größte double die kleiner als x ist on Fri, 01 Jun 2012 10:26:55 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/8250">@Swordfish</a> Danke, Problem gelöst<br />
Syntax_error Ich meinte nicht der größte double zwischen -&quot;unendlich&quot; und &lt;=x == x, sonder der größte double zwischen -&quot;unendlich&quot; und &lt; x also der größte double der kleiner als x ist.</p>
<p>NACHTRAG: Problem doch nicht gelöst, siehe nächster Beitrag.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2218072</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2218072</guid><dc:creator><![CDATA[tupolew.eljam]]></dc:creator><pubDate>Fri, 01 Jun 2012 10:26:55 GMT</pubDate></item><item><title><![CDATA[Reply to größte double die kleiner als x ist on Fri, 01 Jun 2012 10:26:03 GMT]]></title><description><![CDATA[<p>Noch ein kleines Problem:</p>
<pre><code class="language-cpp">std::cout &lt;&lt; 32.0-std::numeric_limits&lt; double &gt;::epsilon() &lt;&lt; &quot;\n&quot;;
</code></pre>
<p>gibt 32 aus.<br />
Auch im Debugger wird<br />
[/cpp] double t = 32.0-std::numeric_limits&lt; double &gt;::epsilon();<br />
[cpp]<br />
als 32 angezeigt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2218076</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2218076</guid><dc:creator><![CDATA[tupolew.eljam]]></dc:creator><pubDate>Fri, 01 Jun 2012 10:26:03 GMT</pubDate></item><item><title><![CDATA[Reply to größte double die kleiner als x ist on Fri, 01 Jun 2012 10:29:24 GMT]]></title><description><![CDATA[<p>Hört sich stark danach an, als würdest du das falsche Problem lösen. Wozu meinst du denn, das zu brauchen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2218077</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2218077</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Fri, 01 Jun 2012 10:29:24 GMT</pubDate></item><item><title><![CDATA[Reply to größte double die kleiner als x ist on Fri, 01 Jun 2012 10:29:38 GMT]]></title><description><![CDATA[<p>numeric_limits&lt;double&gt;::epsilon() ist der betragsmäßig kleinste darstellbare Wert, das wird also nur bei betragsmäßig sehr kleinen x funktionieren - meistens wird x + epsilon() == x sein.</p>
<p>Es gibt aber in C99 eine Funktion nextafter, die genau das kann. Möglicherweise ist sie auf deiner Plattform schon enthalten.</p>
<pre><code class="language-cpp">double x;

double x_plus_eps  = nextafter(x, x + 1); // Nächster double nach x in Richtung x + 1
double x_minus_eps = nextafter(x, x - 1); // Nächster double nach x in Richtung x - 1
</code></pre>
<p>Statt x + 1 oder x - 1 geht natürlich auch alles mögliche andere; wichtig ist nur, ob es größer oder kleiner als x ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2218078</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2218078</guid><dc:creator><![CDATA[seldon]]></dc:creator><pubDate>Fri, 01 Jun 2012 10:29:38 GMT</pubDate></item><item><title><![CDATA[Reply to größte double die kleiner als x ist on Fri, 01 Jun 2012 10:31:44 GMT]]></title><description><![CDATA[<p>tupolew.eljam schrieb:</p>
<blockquote>
<p>Ich brauche in meinem Jump'n Run Spiel eine Funktion die von einem vorhandenen double x den größten double herausfindet im Bereich von -unendlich bis &lt;x.</p>
</blockquote>
<p>Wozu? Vielleicht gibt's ja noch eine andere Lösung.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2218079</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2218079</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Fri, 01 Jun 2012 10:31:44 GMT</pubDate></item><item><title><![CDATA[Reply to größte double die kleiner als x ist on Fri, 01 Jun 2012 10:59:42 GMT]]></title><description><![CDATA[<p>mit dieser Funktion funktioniert das ganze.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2218083</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2218083</guid><dc:creator><![CDATA[tupolew.eljam]]></dc:creator><pubDate>Fri, 01 Jun 2012 10:59:42 GMT</pubDate></item><item><title><![CDATA[Reply to größte double die kleiner als x ist on Fri, 01 Jun 2012 11:04:38 GMT]]></title><description><![CDATA[<p>tupolew.eljam schrieb:</p>
<blockquote>
<p>mit dieser Funktion funktioniert das ganze.</p>
</blockquote>
<p>Ich möchte nochmal auf den Beitrag von Bashar aufmerksam machen. Noch nie hat ein Spieleprogrammierer diese Funktion gebraucht. Du löst höchstwahrscheinlich ein ganz einfaches Problem auf hochkomplizierte Weise. Bitte sag uns, was du erreichen möchtest, nicht wie du denkst, wie du dein Problem lösen kannst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2218084</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2218084</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Fri, 01 Jun 2012 11:04:38 GMT</pubDate></item><item><title><![CDATA[Reply to größte double die kleiner als x ist on Fri, 01 Jun 2012 13:44:49 GMT]]></title><description><![CDATA[<p>Ein interessantes Problem.</p>
<p>Mein Vorschlag dazu:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;limits&gt;
#include &lt;iomanip&gt;

double nextBiggestDouble(double Value) {
	double loLimit = 1;
	double hiLimit = 2;

	while(true) {
		if(loLimit&lt;=Value &amp;&amp; Value&lt;hiLimit) {
			return Value+loLimit*DBL_EPSILON;
		} else {
			loLimit*=2;
			hiLimit*=2;
		}
	}
}

int main() {
	double Input;
	do {
		std::cin&gt;&gt;Input;
		std::cout&lt;&lt;std::scientific&lt;&lt;std::setprecision(17)&lt;&lt;nextBiggestDouble(Input)&lt;&lt;std::endl;
	} while(Input!=0.0);
}
</code></pre>
<p>Getestet für Zahlen &gt;=1. Für negative Zahlen müsste man nochmal ran.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2218140</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2218140</guid><dc:creator><![CDATA[dudeldu]]></dc:creator><pubDate>Fri, 01 Jun 2012 13:44:49 GMT</pubDate></item><item><title><![CDATA[Reply to größte double die kleiner als x ist on Fri, 01 Jun 2012 14:42:01 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">double nextBiggestDouble(double Value) 
{
    ++ *(reinterpret_cast&lt;int64_t*&gt;(&amp;Value)); 
    return Value;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2218171</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2218171</guid><dc:creator><![CDATA[dideldum]]></dc:creator><pubDate>Fri, 01 Jun 2012 14:42:01 GMT</pubDate></item><item><title><![CDATA[Reply to größte double die kleiner als x ist on Fri, 01 Jun 2012 16:32:08 GMT]]></title><description><![CDATA[<p>Ich brauche die Funktion daher, da ich eine TileEngine habe, bei der in regelmäßigen Abständen ein Kachel kommt, wenn z.B alle 32 Pixel ein neuer Kachel kommt, dann hat ein Kachel die größe 31.99999999999 Pixel denn bei 32 beginnt schon der nächste Kachel. Also Kachel 0 geht auf der X-Achse beispielsweise von 0-32.9999999999999999999999999999999999. Die Funktion nextafter(x, y) funktioniert. Bei dieser habe ich bis jetzt noch keinen Rundungsfehler bekommen. bei Interesse der Quellcode (nicht immer der aktuellste) lade ich auf <a href="https://github.com/tupolew/jump_run" rel="nofollow">https://github.com/tupolew/jump_run</a> hoch.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2218214</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2218214</guid><dc:creator><![CDATA[tupolew.eljam]]></dc:creator><pubDate>Fri, 01 Jun 2012 16:32:08 GMT</pubDate></item><item><title><![CDATA[Reply to größte double die kleiner als x ist on Fri, 01 Jun 2012 16:57:13 GMT]]></title><description><![CDATA[<p>tupolew.eljam schrieb:</p>
<blockquote>
<p>wenn z.B alle 32 Pixel ein neuer Kachel kommt, dann hat ein Kachel die größe 31.99999999999 Pixel</p>
</blockquote>
<p>Nein, <em>die</em> Kachel hat die Grösse 32 Pixel.</p>
<p>Oder zumindest sehe ich nicht, wo du genau den Wert 31.999... konkret benötigst, selbst wenn du eine spezielle Definition für &quot;Grösse&quot; verwendest. Kannst du das erläutern?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2218223</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2218223</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Fri, 01 Jun 2012 16:57:13 GMT</pubDate></item><item><title><![CDATA[Reply to größte double die kleiner als x ist on Fri, 01 Jun 2012 17:16:04 GMT]]></title><description><![CDATA[<p>Die Kachel hat die Größe 32. Nur er endet immer bei einer x.99999999 Zahl. Da ja bei der nächsten vollen Zahl schon der nächste Kachel beginnt. Kachel 1 beginnt bei 0 und endet bei 31.99999999999999, Kachel 2 beginnt bei 32.0 und Endet bei 63.99999999999999.<br />
Ich habe halt noch NULL Erfahrung in Spieleprogrammierung, da ich Mittelstufenschüler bin und Programmieren nur als Hobby mache.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2218230</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2218230</guid><dc:creator><![CDATA[tupolew.eljam]]></dc:creator><pubDate>Fri, 01 Jun 2012 17:16:04 GMT</pubDate></item><item><title><![CDATA[Reply to größte double die kleiner als x ist on Fri, 01 Jun 2012 18:22:57 GMT]]></title><description><![CDATA[<p>Warum baust du ein theoretisches Konstrukt, daß du sowieso nicht darstellen kannst? WTF?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2218246</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2218246</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Fri, 01 Jun 2012 18:22:57 GMT</pubDate></item><item><title><![CDATA[Reply to größte double die kleiner als x ist on Fri, 01 Jun 2012 18:24:58 GMT]]></title><description><![CDATA[<p>Wieso brauchst du den letzten Wert einer Kachel? Reicht es nicht für alles was man so tun kann, dass 32 der erste Wert ist, der nicht mehr zur Kachel gehört?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2218247</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2218247</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Fri, 01 Jun 2012 18:24:58 GMT</pubDate></item><item><title><![CDATA[Reply to größte double die kleiner als x ist on Fri, 01 Jun 2012 18:28:07 GMT]]></title><description><![CDATA[<p>Ich weiß halt nicht wie ich es anders machen soll, bis jetzt funktioniert alles soweit ganz gut.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2218250</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2218250</guid><dc:creator><![CDATA[tupolew.eljam]]></dc:creator><pubDate>Fri, 01 Jun 2012 18:28:07 GMT</pubDate></item><item><title><![CDATA[Reply to größte double die kleiner als x ist on Fri, 01 Jun 2012 18:38:45 GMT]]></title><description><![CDATA[<p>Ach, &quot;es&quot;. Dann ist ja klar.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2218255</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2218255</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Fri, 01 Jun 2012 18:38:45 GMT</pubDate></item><item><title><![CDATA[Reply to größte double die kleiner als x ist on Fri, 01 Jun 2012 18:45:31 GMT]]></title><description><![CDATA[<p>RE: Ach, &quot;es&quot;. Dann ist ja klar. &gt; Was meinst du?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2218259</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2218259</guid><dc:creator><![CDATA[tupolew.eljam]]></dc:creator><pubDate>Fri, 01 Jun 2012 18:45:31 GMT</pubDate></item><item><title><![CDATA[Reply to größte double die kleiner als x ist on Fri, 01 Jun 2012 19:09:56 GMT]]></title><description><![CDATA[<p>wenn dir das nicht klar ist, wem dann? wir wissen ja nicht, was &quot;es&quot; ist in</p>
<blockquote>
<p>Ich weiß halt nicht wie ich es anders machen soll</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/2218267</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2218267</guid><dc:creator><![CDATA[otze]]></dc:creator><pubDate>Fri, 01 Jun 2012 19:09:56 GMT</pubDate></item><item><title><![CDATA[Reply to größte double die kleiner als x ist on Fri, 01 Jun 2012 19:29:20 GMT]]></title><description><![CDATA[<p>tupolew.eljam schrieb:</p>
<blockquote>
<p>Die Kachel hat die Größe 32. Nur er endet immer bei einer x.99999999 Zahl. Da ja bei der nächsten vollen Zahl schon der nächste Kachel beginnt. Kachel 1 beginnt bei 0 und endet bei 31.99999999999999, Kachel 2 beginnt bei 32.0 und Endet bei 63.99999999999999.</p>
</blockquote>
<p>Nochmals: Wo genau benötigst du den Wert mit .999... als Nachkommastelle <strong>konkret</strong>? Wie gedenkst du ihn in den Code einzubauen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2218268</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2218268</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Fri, 01 Jun 2012 19:29:20 GMT</pubDate></item></channel></rss>