<?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[static_cast&amp;lt;double&amp;gt;(float) sinnvoll]]></title><description><![CDATA[<p>Hi,</p>
<p>möglicherweise eine blöde Frage, aber mich würde interessieren, in welchen Fällen/aus welchen Gründen es sinnvoll ist einen expliziten cast von float in double durchzuführen (siehe Titel). Oder kann man sich bedenkenlos auf die implizite Umwandlung verlassen und castet nur dann explizit, wenn man jedermann kenntlich machen will, dass der Datentyp gewandelt wird.<br />
Habe das kürzlich in einem Codeauszug gelesen und war ein wenig verwundert.</p>
<p>Danke vorab!</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/220657/static_cast-lt-double-gt-float-sinnvoll</link><generator>RSS for Node</generator><lastBuildDate>Wed, 07 Oct 2026 00:09:41 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/220657.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 19 Aug 2008 10:37:13 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to static_cast&amp;lt;double&amp;gt;(float) sinnvoll on Tue, 19 Aug 2008 10:37:13 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>möglicherweise eine blöde Frage, aber mich würde interessieren, in welchen Fällen/aus welchen Gründen es sinnvoll ist einen expliziten cast von float in double durchzuführen (siehe Titel). Oder kann man sich bedenkenlos auf die implizite Umwandlung verlassen und castet nur dann explizit, wenn man jedermann kenntlich machen will, dass der Datentyp gewandelt wird.<br />
Habe das kürzlich in einem Codeauszug gelesen und war ein wenig verwundert.</p>
<p>Danke vorab!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1567454</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1567454</guid><dc:creator><![CDATA[float2double]]></dc:creator><pubDate>Tue, 19 Aug 2008 10:37:13 GMT</pubDate></item><item><title><![CDATA[Reply to static_cast&amp;lt;double&amp;gt;(float) sinnvoll on Tue, 19 Aug 2008 10:41:11 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;iostream&gt;

void doIt(float a){
    std::cout &lt;&lt; &quot;float&quot; &lt;&lt; std::endl;
}

void doIt(double a){
    std::cout &lt;&lt; &quot;double&quot; &lt;&lt; std::endl;
}

int main(int argc, char *argv[]){
    float a = 0.0;
    doIt(a);
    doIt(static_cast&lt;double&gt;(a));
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1567456</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1567456</guid><dc:creator><![CDATA[Fellhuhn]]></dc:creator><pubDate>Tue, 19 Aug 2008 10:41:11 GMT</pubDate></item><item><title><![CDATA[Reply to static_cast&amp;lt;double&amp;gt;(float) sinnvoll on Tue, 19 Aug 2008 10:45:56 GMT]]></title><description><![CDATA[<p>der implizite cast wird nat*rlich nur durchgef*hrt, wenn es notwendig ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1567458</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1567458</guid><dc:creator><![CDATA[zwutz]]></dc:creator><pubDate>Tue, 19 Aug 2008 10:45:56 GMT</pubDate></item><item><title><![CDATA[Reply to static_cast&amp;lt;double&amp;gt;(float) sinnvoll on Tue, 19 Aug 2008 10:53:09 GMT]]></title><description><![CDATA[<p>Gutes Beispiel, danke für die schnellen Antworten!<br />
Ich glaube, ich war deswegen irritiert, weil ich einen solchen cast in einem Konstruktor-Aufruf gesehen habe, in dem ein double verlangt, aber ein float (bzw. static_cast&lt;double&gt;(float)) übergeben wird. Dort ist die Umwandlung notwendig, der implizite cast wird also in jedem Fall durchgeführt und macht keine Probleme.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1567460</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1567460</guid><dc:creator><![CDATA[float2double]]></dc:creator><pubDate>Tue, 19 Aug 2008 10:53:09 GMT</pubDate></item><item><title><![CDATA[Reply to static_cast&amp;lt;double&amp;gt;(float) sinnvoll on Tue, 19 Aug 2008 11:09:58 GMT]]></title><description><![CDATA[<p>So ein Cast ist an vielen Stellen nötig wo man vielleicht meinen könnte er wäre es nicht:</p>
<pre><code class="language-cpp">void foo(int);
void foo(double);

void test()
{
    float a = 0;
    foo(a); // geht nicht
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1567471</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1567471</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Tue, 19 Aug 2008 11:09:58 GMT</pubDate></item></channel></rss>