<?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[float zu double und anders herum - Standard?]]></title><description><![CDATA[<p>Hi.<br />
Ich wollte mal wissen ob im Standard folgendes Verhalten wohldefiniert ist:</p>
<pre><code class="language-cpp">float myFloat = static_cast&lt;float&gt;(myDouble);
// und anders herum
</code></pre>
<p>Und für die Zukunft: Wie finde ich so etwas mal selber raus? Wie soll ich in de(m|n) Dokument(en) gerade die Stelle finden, die das definiert?</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/271747/float-zu-double-und-anders-herum-standard</link><generator>RSS for Node</generator><lastBuildDate>Sat, 29 Aug 2026 06:25:51 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/271747.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 03 Aug 2010 10:24:47 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to float zu double und anders herum - Standard? on Tue, 03 Aug 2010 10:24:47 GMT]]></title><description><![CDATA[<p>Hi.<br />
Ich wollte mal wissen ob im Standard folgendes Verhalten wohldefiniert ist:</p>
<pre><code class="language-cpp">float myFloat = static_cast&lt;float&gt;(myDouble);
// und anders herum
</code></pre>
<p>Und für die Zukunft: Wie finde ich so etwas mal selber raus? Wie soll ich in de(m|n) Dokument(en) gerade die Stelle finden, die das definiert?</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1935534</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1935534</guid><dc:creator><![CDATA[theliquidwave]]></dc:creator><pubDate>Tue, 03 Aug 2010 10:24:47 GMT</pubDate></item><item><title><![CDATA[Reply to float zu double und anders herum - Standard? on Tue, 03 Aug 2010 10:33:59 GMT]]></title><description><![CDATA[<p>Nein:</p>
<p>C++ Standard schrieb:</p>
<blockquote>
<p><strong>Floating point conversions</strong></p>
<p>An rvalue of floating point type can be converted to an rvalue of another floating point type. If the source value can be exactly represented in the destination type, the result of the conversion is that exact representation. If the source value is between two adjacent destination values, the result of the conversion is an implementation-defined choice of either of those values. Otherwise, the behavior is undefined.</p>
<p>The conversions allowed as floating point promotions are excluded from the set of floating point conversions.</p>
<p>[...]</p>
<p><strong>Floating point promotion</strong></p>
<p>An rvalue of type float can be converted to an rvalue of type double. The value is unchanged.<br />
This conversion is called <em>floating point promotion</em>.</p>
</blockquote>
<p>theliquidwave schrieb:</p>
<blockquote>
<p>Und für die Zukunft: Wie finde ich so etwas mal selber raus? Wie soll ich in de(m|n) Dokument(en) gerade die Stelle finden, die das definiert?</p>
</blockquote>
<p>Im Inhaltsverzeichnis? Ich denke die Überschrift &quot;Standard conversions: Floating point conversions&quot; ist doch recht aussagekräftig.</p>
<p>Ansonsten: Überfliege einmal den Standard. Dann weißt du, was ungefähr wo steht. Versuche Fragen zum Standard die hier im Forum gestellt werden selbstständig zu beantworten. Und sei es durch Volltextsuche, wenn du im Inhaltsverzeichnis nichts findest. Dann findest du dich nach kurzer Zeit zumindest grob im Standard zurecht.</p>
<p>(Wobei ich zugeben muss, dass einige Sachen im Standard nur sehr obskur und indirekt definiert werden. Paradebeispiel für etwas schwer zu findendes ist meiner Meinung nach die Mindestgröße der integralen Typen.)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1935536</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1935536</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Tue, 03 Aug 2010 10:33:59 GMT</pubDate></item><item><title><![CDATA[Reply to float zu double und anders herum - Standard? on Tue, 03 Aug 2010 17:53:00 GMT]]></title><description><![CDATA[<p>Das &quot;Otherwise, the behavior is undefined&quot; bezieht sich nur auf den Fall, in dem sich der <code>double</code> -Wert ausserhalb des <code>float</code> -Wertebereichs befindet und deshalb nicht zwischen zwei benachbarten möglichen <code>float</code> -Repräsentationen liegt. Sonst (und mit dem Fall hat man wohl am meisten zu tun) wird die Konversion klappen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1935736</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1935736</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Tue, 03 Aug 2010 17:53:00 GMT</pubDate></item><item><title><![CDATA[Reply to float zu double und anders herum - Standard? on Tue, 03 Aug 2010 19:02:41 GMT]]></title><description><![CDATA[<p>Dann habe ich ja Glück gehabt. Es geht bei mir nur um Werte zwischen -1.0 und max. 10000.0 - das sollte ja problemlos hinhauen <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>Gruß und Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1935776</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1935776</guid><dc:creator><![CDATA[theliquidwave]]></dc:creator><pubDate>Tue, 03 Aug 2010 19:02:41 GMT</pubDate></item><item><title><![CDATA[Reply to float zu double und anders herum - Standard? on Tue, 03 Aug 2010 19:07:43 GMT]]></title><description><![CDATA[<p>Ach so, es geht nur darum, ob es überhaupt funktioniert. Ich hatte gedacht es ginge darum, ob das exakte Ergebnis definiert wäre (Was es nicht unbedingt ist. Siehe oben).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1935779</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1935779</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Tue, 03 Aug 2010 19:07:43 GMT</pubDate></item><item><title><![CDATA[Reply to float zu double und anders herum - Standard? on Tue, 03 Aug 2010 19:25:45 GMT]]></title><description><![CDATA[<p>Jupp. Genauigkeit spielt eigentlich gar keine Rolle. Hauptsache aus -1.0 wird nicht 200.0</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1935788</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1935788</guid><dc:creator><![CDATA[theliquidwave]]></dc:creator><pubDate>Tue, 03 Aug 2010 19:25:45 GMT</pubDate></item></channel></rss>