<?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[Ergebnis von 16 Bit Multiplikation? Wieder 16 Bit oder 32 Bit?]]></title><description><![CDATA[<p>Hallo C++ler,</p>
<p>kann mir jemand weiterhelfen?</p>
<p>Wer legt fest, ob das Ergebnis von zwei 16-Bit-Variablen wiederum ein 16 Bit Wert ergibt oder einen 32 Bit Wert.</p>
<p>Ich habe folgenden Fall:</p>
<pre><code>int a = 30000, b = 10; // int = 16 bit
long result = a * b;   // long = 32 bit
</code></pre>
<p>Auf 2 Prozessoren hatte ich unterschiedliche Ergebnisse.<br />
Einmal war das Ergebnis 300000, ein andermal -27679.</p>
<p>Legt der Standard fest, wie das Ergebnis sein muss oder ist das compilerabhängig?</p>
<p>Greets,<br />
Zero</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/295397/ergebnis-von-16-bit-multiplikation-wieder-16-bit-oder-32-bit</link><generator>RSS for Node</generator><lastBuildDate>Sat, 15 Aug 2026 10:28:56 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/295397.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 13 Nov 2011 14:48:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Ergebnis von 16 Bit Multiplikation? Wieder 16 Bit oder 32 Bit? on Sun, 13 Nov 2011 14:48:00 GMT]]></title><description><![CDATA[<p>Hallo C++ler,</p>
<p>kann mir jemand weiterhelfen?</p>
<p>Wer legt fest, ob das Ergebnis von zwei 16-Bit-Variablen wiederum ein 16 Bit Wert ergibt oder einen 32 Bit Wert.</p>
<p>Ich habe folgenden Fall:</p>
<pre><code>int a = 30000, b = 10; // int = 16 bit
long result = a * b;   // long = 32 bit
</code></pre>
<p>Auf 2 Prozessoren hatte ich unterschiedliche Ergebnisse.<br />
Einmal war das Ergebnis 300000, ein andermal -27679.</p>
<p>Legt der Standard fest, wie das Ergebnis sein muss oder ist das compilerabhängig?</p>
<p>Greets,<br />
Zero</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2143963</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2143963</guid><dc:creator><![CDATA[Zero_Clamping]]></dc:creator><pubDate>Sun, 13 Nov 2011 14:48:00 GMT</pubDate></item><item><title><![CDATA[Reply to Ergebnis von 16 Bit Multiplikation? Wieder 16 Bit oder 32 Bit? on Sun, 13 Nov 2011 15:08:53 GMT]]></title><description><![CDATA[<p>Stichwort <em>Integral Promotion</em>, in Kürze etwa: Das Ergebnis von Ganzzahlarithmetik hat mindestens <code>int</code> -Genauigkeit bzw. den genaueren Typen beider Operanden.</p>
<pre><code class="language-cpp">short * short == int
int   * int   == int
long  * int   == long
</code></pre>
<p>Du müsstest also casten. Aber was ist das für ein System, wo <code>int</code> nur 16 Bit gross ist?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2143968</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2143968</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Sun, 13 Nov 2011 15:08:53 GMT</pubDate></item><item><title><![CDATA[Reply to Ergebnis von 16 Bit Multiplikation? Wieder 16 Bit oder 32 Bit? on Mon, 14 Nov 2011 12:01:16 GMT]]></title><description><![CDATA[<p>Hallo,<br />
vielen Dank für den Beitrag.</p>
<p>int ist auf meinem DSP von TI 16 Bit groß (sizeof(int)) liefert hier sogar 1, 1 entspricht 16 Bit.</p>
<p>Danke nochmals,<br />
Zero</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2144328</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2144328</guid><dc:creator><![CDATA[Zero_Clamping]]></dc:creator><pubDate>Mon, 14 Nov 2011 12:01:16 GMT</pubDate></item><item><title><![CDATA[Reply to Ergebnis von 16 Bit Multiplikation? Wieder 16 Bit oder 32 Bit? on Mon, 14 Nov 2011 16:25:33 GMT]]></title><description><![CDATA[<p>Zero_Clamping schrieb:</p>
<blockquote>
<p>Hallo,<br />
vielen Dank für den Beitrag.</p>
<p>int ist auf meinem DSP von TI 16 Bit groß (sizeof(int)) liefert hier sogar 1, 1 entspricht 16 Bit.</p>
<p>Danke nochmals,<br />
Zero</p>
</blockquote>
<p>Kannst du mal die Ausgabe von</p>
<pre><code>#include &lt;climits&gt;
#include &lt;cstsio&gt;

int main()
{
  std::printf(&quot;bits: %d\n&quot;, CHAR_BIT);
}
</code></pre>
<p>posten? Würde mich interessieren ob die Konstante auf diesem System dann 16 ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2144449</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2144449</guid><dc:creator><![CDATA[Neugieriger]]></dc:creator><pubDate>Mon, 14 Nov 2011 16:25:33 GMT</pubDate></item><item><title><![CDATA[Reply to Ergebnis von 16 Bit Multiplikation? Wieder 16 Bit oder 32 Bit? on Tue, 15 Nov 2011 09:38:48 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>short int, int und char sind in dem Fall sogar dasselbe.<br />
Alles 16 bit Variablen,<br />
alle sizeof-Operatoren auf diese Datentypen liefern 1.</p>
<p>So ist es eben <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>Damit macht die erste Aussage auch Sinn:</p>
<p>short * short = int</p>
<p>Wenn int jetzt eben nur 16 Bit sind, dann ist das erwartete Ergebnis ok.</p>
<p>Zero</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2144725</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2144725</guid><dc:creator><![CDATA[Zero_Clamping]]></dc:creator><pubDate>Tue, 15 Nov 2011 09:38:48 GMT</pubDate></item></channel></rss>