<?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[Was kostet C style Typwandlung]]></title><description><![CDATA[<p>Hi,</p>
<p>Was kostet eigentlich eine Typumwandlung.</p>
<pre><code class="language-cpp">unsigned int a;
signed int b;
signed int c;

c=b+(signed int)a;
</code></pre>
<p>kann ma das so lassen oder sollte man a von vorne herein als signed int machen.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/168532/was-kostet-c-style-typwandlung</link><generator>RSS for Node</generator><lastBuildDate>Wed, 16 Sep 2026 11:10:33 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/168532.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 23 Dec 2006 20:58:49 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Was kostet C style Typwandlung on Sat, 23 Dec 2006 20:58:49 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>Was kostet eigentlich eine Typumwandlung.</p>
<pre><code class="language-cpp">unsigned int a;
signed int b;
signed int c;

c=b+(signed int)a;
</code></pre>
<p>kann ma das so lassen oder sollte man a von vorne herein als signed int machen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1197151</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1197151</guid><dc:creator><![CDATA[Frugger]]></dc:creator><pubDate>Sat, 23 Dec 2006 20:58:49 GMT</pubDate></item><item><title><![CDATA[Reply to Was kostet C style Typwandlung on Sat, 23 Dec 2006 21:03:13 GMT]]></title><description><![CDATA[<p>Gibts zu Weihnachten im Angebot:</p>
<p>3 Umwandlungen: 4,99EUR<br />
Bis zum 24.12. gilt: Buy 3, get 1 free!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1197155</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1197155</guid><dc:creator><![CDATA[Christkind]]></dc:creator><pubDate>Sat, 23 Dec 2006 21:03:13 GMT</pubDate></item><item><title><![CDATA[Reply to Was kostet C style Typwandlung on Sat, 23 Dec 2006 21:13:54 GMT]]></title><description><![CDATA[<p>Bei ner x86 CPU würde der Compiler wohl einfach die verwendeten Befehle ändern, so dass eine signed Addition verwendet wird mit den ersten 16Bit von a.<br />
Also gäbe es kein Overhead in diesem Fall.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1197164</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1197164</guid><dc:creator><![CDATA[lolz]]></dc:creator><pubDate>Sat, 23 Dec 2006 21:13:54 GMT</pubDate></item><item><title><![CDATA[Reply to Was kostet C style Typwandlung on Sat, 23 Dec 2006 21:55:34 GMT]]></title><description><![CDATA[<p>Die Konvertierungsregeln sind bewusst derart gewählt, dass die Konvertierung bei der heute üblichen 2er-Komplementdarstellung ein No-op ist (Konvertierung zu großer Werte in signed ints ist trotzdem undefiniert!). Der Vorteil der 2er-Komplementdarstellung ist ja eben, dass für die einfachen Operationen Addition, Subtraktion und Multiplikation nicht zwei verschiedene Befehle benötigt werden. Im Übrigen ist das hier sowieso klar, da das Ergebnis der Konvertierung unmittelbar wieder zurück konvertiert werden muss, um den gemeinsamen Basistyp für die Addition zu haben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1197185</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1197185</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Sat, 23 Dec 2006 21:55:34 GMT</pubDate></item><item><title><![CDATA[Reply to Was kostet C style Typwandlung on Sun, 24 Dec 2006 03:13:55 GMT]]></title><description><![CDATA[<p>@Frugger:<br />
Diese Umwandlung kostet nix, weil nix umgewandelt wird. Was Addition und Subtraktion angeht ist es egal ob man mit signed oder unsigned Werten arbeitet, soll heissen: es gibt keinen &quot;signed&quot; oder &quot;unsigned&quot; Addierbefehl, es gibt nur einen &quot;allgemeinen&quot; Addierbefehl der auf Grund der Binärdarstellung von positiven und negativen Zahlen mit beidem funktioniert.</p>
<p>Was anderes ist es wenn man z.B. ein char in einen int umwandelt, das kostet meist 1 oder 2 Befehle.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1197254</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1197254</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Sun, 24 Dec 2006 03:13:55 GMT</pubDate></item><item><title><![CDATA[Reply to Was kostet C style Typwandlung on Sun, 24 Dec 2006 08:16:02 GMT]]></title><description><![CDATA[<p>Richtig teuer werden float-umwandlungen, weil hier die Binärdarstellung umgewandelt werden muß. (Gilt auch für float nach double)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1197272</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1197272</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sun, 24 Dec 2006 08:16:02 GMT</pubDate></item><item><title><![CDATA[Reply to Was kostet C style Typwandlung on Sun, 24 Dec 2006 09:28:55 GMT]]></title><description><![CDATA[<p>Christkind schrieb:</p>
<blockquote>
<p>Gibts zu Weihnachten im Angebot:</p>
<p>3 Umwandlungen: 4,99EUR<br />
Bis zum 24.12. gilt: Buy 3, get 1 free!</p>
</blockquote>
<p>Hab gleich mal 10 gekauft, braucht man doch immer wieder.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1197290</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1197290</guid><dc:creator><![CDATA[Käufer]]></dc:creator><pubDate>Sun, 24 Dec 2006 09:28:55 GMT</pubDate></item><item><title><![CDATA[Reply to Was kostet C style Typwandlung on Sun, 24 Dec 2006 10:05:34 GMT]]></title><description><![CDATA[<p>hustbaer schrieb:</p>
<blockquote>
<p>Diese Umwandlung kostet nix, weil nix umgewandelt wird.</p>
</blockquote>
<p>Auf Sprachebene betrachtet, muss man aber schon sagen, dass hier Umwandlungen stattfinden. Erst wird durch den Cast a in signed int &quot;umgewandelt&quot;, durch usual arithmetic conversion wieder zurück nach unsigned int gewandelt. In der Praxis wird dadurch aber kein zusätzlicher Code erzeugt, da der Operand dann so verwendet werden kann, wie er deklariert ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1197295</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1197295</guid><dc:creator><![CDATA[groovemaster]]></dc:creator><pubDate>Sun, 24 Dec 2006 10:05:34 GMT</pubDate></item><item><title><![CDATA[Reply to Was kostet C style Typwandlung on Sun, 24 Dec 2006 16:50:26 GMT]]></title><description><![CDATA[<p>groovemaster schrieb:</p>
<blockquote>
<p>hustbaer schrieb:</p>
<blockquote>
<p>Diese Umwandlung kostet nix, weil nix umgewandelt wird.</p>
</blockquote>
<p>Auf Sprachebene betrachtet, muss man aber schon sagen, dass hier Umwandlungen stattfinden. Erst wird durch den Cast a in signed int &quot;umgewandelt&quot;, durch usual arithmetic conversion wieder zurück nach unsigned int gewandelt. In der Praxis wird dadurch aber kein zusätzlicher Code erzeugt, da der Operand dann so verwendet werden kann, wie er deklariert ist.</p>
</blockquote>
<p>Ja, Freund der Blasmusik, das hier ein Cast steht und das formal eine &quot;Typenumwandlung&quot; ist lese ich selbst bzw. weiss ich selbst. Es wird trotzdem im erzeugten Code nix umgewandelt.<br />
Und wieso bitte (formal betrachtet) wieder zurück? b und c sind signed, a nach signed gecastet - was sollte nach unsigned gewandelt werden?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1197444</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1197444</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Sun, 24 Dec 2006 16:50:26 GMT</pubDate></item></channel></rss>