<?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[Unsigned LowByte und HighByte nach int]]></title><description><![CDATA[<p>Hallo!<br />
Ich brauche eine Funktion, die mir aus einem unsigned LowByte und HighByte<br />
ein int macht. Die beiden Bytes sind codiert im 2er Komplement.<br />
Folgendes brachte nicht das gewünschte Ergebnis:</p>
<pre><code class="language-cpp">int LowHighToSigned(unsigned _LowByte, unsigned _HighByte)
{
    unsigned Decimal;
    Decimal = (_HighByte &lt;&lt; 8) | _LowByte;

    return (~Decimal) + 1;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/227590/unsigned-lowbyte-und-highbyte-nach-int</link><generator>RSS for Node</generator><lastBuildDate>Tue, 29 Sep 2026 21:55:15 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/227590.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 17 Nov 2008 14:25:47 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Unsigned LowByte und HighByte nach int on Mon, 17 Nov 2008 14:25:47 GMT]]></title><description><![CDATA[<p>Hallo!<br />
Ich brauche eine Funktion, die mir aus einem unsigned LowByte und HighByte<br />
ein int macht. Die beiden Bytes sind codiert im 2er Komplement.<br />
Folgendes brachte nicht das gewünschte Ergebnis:</p>
<pre><code class="language-cpp">int LowHighToSigned(unsigned _LowByte, unsigned _HighByte)
{
    unsigned Decimal;
    Decimal = (_HighByte &lt;&lt; 8) | _LowByte;

    return (~Decimal) + 1;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1615990</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1615990</guid><dc:creator><![CDATA[[[global:former_user]]]]></dc:creator><pubDate>Mon, 17 Nov 2008 14:25:47 GMT</pubDate></item><item><title><![CDATA[Reply to Unsigned LowByte und HighByte nach int on Mon, 17 Nov 2008 22:05:53 GMT]]></title><description><![CDATA[<p>Na dann antworte ich mal selber. So hat's funktioniert:</p>
<pre><code class="language-cpp">int LowHighToSigned(unsigned _LowByte, unsigned _HighByte)
{
    int16_t Decimal;
    Decimal = (_HighByte &lt;&lt; 8) | _LowByte;

    //if negative (leading 1)
    if (Decimal &amp; 32768 == 32768)
    {
        Decimal = -((~Decimal) + 1);
    }

    return Decimal;
}
</code></pre>
<p>Ob das die beste Lösung ist, weiss ich nicht, aber es geht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1616193</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1616193</guid><dc:creator><![CDATA[[[global:former_user]]]]></dc:creator><pubDate>Mon, 17 Nov 2008 22:05:53 GMT</pubDate></item></channel></rss>