<?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[double array zu float array]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe ein double Array: double d[3];<br />
und eine Funktion, die ein float array erwartet: void foo(float f[3);<br />
Wie uebergebe ich das array d jetzt an foo? ein foo(d) geht nicht. Wieso geht nicht foo( static_cast&lt;float*&gt;(d) )?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/286521/double-array-zu-float-array</link><generator>RSS for Node</generator><lastBuildDate>Thu, 20 Aug 2026 22:22:45 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/286521.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 11 May 2011 12:36:09 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to double array zu float array on Wed, 11 May 2011 12:36:09 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe ein double Array: double d[3];<br />
und eine Funktion, die ein float array erwartet: void foo(float f[3);<br />
Wie uebergebe ich das array d jetzt an foo? ein foo(d) geht nicht. Wieso geht nicht foo( static_cast&lt;float*&gt;(d) )?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2061733</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2061733</guid><dc:creator><![CDATA[caster2]]></dc:creator><pubDate>Wed, 11 May 2011 12:36:09 GMT</pubDate></item><item><title><![CDATA[Reply to double array zu float array on Wed, 11 May 2011 12:40:43 GMT]]></title><description><![CDATA[<p>Float und double haben unterschiedliche Größen, daher sind auch Pointer da drauf total inkompatibel, weshalb die der Compiler zurecht vor solch einem static_cast bewahrt. Selbst wenn du ihn mit einem reinterpret_cast zwingen würdest, würde das falsche herauskommen.</p>
<p>Abhilfe:<br />
Mach so etwas gar nicht erst. Wieso benutzt du rohe Arrays? Wieso mischt du unterschiedliche Fließkommatypen? Dein Programm wäre in jedweder Hinsicht besser, würdest du dies nicht tun.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2061735</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2061735</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Wed, 11 May 2011 12:40:43 GMT</pubDate></item><item><title><![CDATA[Reply to double array zu float array on Wed, 11 May 2011 12:40:17 GMT]]></title><description><![CDATA[<p>caster2 schrieb:</p>
<blockquote>
<p>Wieso geht nicht foo( static_cast&lt;float*&gt;(d) )?</p>
</blockquote>
<p>Weil d nunmal kein float-Array ist. Wenn das gehen würde (mit reinterpret_cast kannst du den Compiler dazu kriegen), wäre der Code trotzdem nicht sinnvoll, weil dann auf das double-Array zugegriffen würde, als ob es ein float-Array wäre. Also z.b. würde das erste double-Element als zwei float-Elemente interpretiert.<br />
Dir bleibt nichts anderes übrig, als das Array Element für Element in ein neues float-Array umzukopieren und dieses zu übergeben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2061736</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2061736</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Wed, 11 May 2011 12:40:17 GMT</pubDate></item><item><title><![CDATA[Reply to double array zu float array on Wed, 11 May 2011 12:56:08 GMT]]></title><description><![CDATA[<p>Ja, das leuchtet ein. Was ich dann jedoch nicht verstehe ist, wieso dieser Code ohne Fehler und sogar ohne Warnings kompiliert:</p>
<pre><code class="language-cpp">osg::Vec3 p;

Vertex(double pos[3]) : p(pos[0], pos[1], pos[2]),
</code></pre>
<p>Der Ctor von Vec3 sieht so aus: Vec3::Vec3(float x, float y, float z). Wieso klappt das, obwohl ich ihm doch 3 double uebergebe?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2061750</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2061750</guid><dc:creator><![CDATA[caster2]]></dc:creator><pubDate>Wed, 11 May 2011 12:56:08 GMT</pubDate></item><item><title><![CDATA[Reply to double array zu float array on Wed, 11 May 2011 12:57:32 GMT]]></title><description><![CDATA[<p>Die doubles werden in float konvertiert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2061752</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2061752</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Wed, 11 May 2011 12:57:32 GMT</pubDate></item><item><title><![CDATA[Reply to double array zu float array on Wed, 11 May 2011 13:08:12 GMT]]></title><description><![CDATA[<p>Bashar schrieb:</p>
<blockquote>
<p>Die doubles werden in float konvertiert.</p>
</blockquote>
<p>Schon klar, aber float ist ja kleiner als double. Sollte es nicht mindestens ein Warning geben? Benutze g++ und hab sogar -Wall an</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2061762</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2061762</guid><dc:creator><![CDATA[caster2]]></dc:creator><pubDate>Wed, 11 May 2011 13:08:12 GMT</pubDate></item><item><title><![CDATA[Reply to double array zu float array on Wed, 11 May 2011 13:12:40 GMT]]></title><description><![CDATA[<p>caster2 schrieb:</p>
<blockquote>
<p>Bashar schrieb:</p>
<blockquote>
<p>Die doubles werden in float konvertiert.</p>
</blockquote>
<p>Schon klar, aber float ist ja kleiner als double. Sollte es nicht mindestens ein Warning geben? Benutze g++ und hab sogar -Wall an</p>
</blockquote>
<p>Und was sollte diese Warnung sagen? Es passiert doch nichts gefährliches.</p>
<p>Bevor jetzt was vonwegen dem Wertebereich kommt: Die maximalen Werte von double und float sind bei fast allen Implementierungen gleich (nämlich unendlich). Der Unterschied ist die Genauigkeit.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2061763</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2061763</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Wed, 11 May 2011 13:12:40 GMT</pubDate></item><item><title><![CDATA[Reply to double array zu float array on Wed, 11 May 2011 14:17:09 GMT]]></title><description><![CDATA[<p>SeppJ schrieb:</p>
<blockquote>
<p>caster2 schrieb:</p>
<blockquote>
<p>Bashar schrieb:</p>
<blockquote>
<p>Die doubles werden in float konvertiert.</p>
</blockquote>
<p>Schon klar, aber float ist ja kleiner als double. Sollte es nicht mindestens ein Warning geben? Benutze g++ und hab sogar -Wall an</p>
</blockquote>
<p>Und was sollte diese Warnung sagen? Es passiert doch nichts gefährliches.</p>
<p>Bevor jetzt was vonwegen dem Wertebereich kommt: Die maximalen Werte von double und float sind bei fast allen Implementierungen gleich (nämlich unendlich). Der Unterschied ist die Genauigkeit.</p>
</blockquote>
<p>Also bei mir kommt 'ne Warnung nach dem Gusto &quot;warning: loss of precision possible&quot;</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2061805</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2061805</guid><dc:creator><![CDATA[Tachyon]]></dc:creator><pubDate>Wed, 11 May 2011 14:17:09 GMT</pubDate></item></channel></rss>