<?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[byteweise manipulation von &amp;quot;größeren&amp;quot; variablen]]></title><description><![CDATA[<p>Hi</p>
<p>wie macht man es in C/C++ ich byteweise variablen manipuliere?</p>
<p>hier mal ein beispiel.</p>
<pre><code class="language-cpp">#include &quot;stdafx.h&quot;
#include &lt;stdio.h&gt;

int _tmain(int argc, _TCHAR* argv[])
{
	unsigned char high=0x12;
	unsigned char low=0x34;
	unsigned short int ausgabe=0x0000;
	//
	//...Code?
	//
	printf(&quot;zahl ist %x&quot;,ausgabe);
	getchar();

	return 0;
}
</code></pre>
<p>die ausgabe soll dann &quot;zahl ist 1234&quot; sein. ich könnte das auch mit mathematische operationen machen, aber ich sehe es nicht ein die resourcen zu verschwenden wenn ich es auch byteweise machen kann.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/182370/byteweise-manipulation-von-quot-größeren-quot-variablen</link><generator>RSS for Node</generator><lastBuildDate>Tue, 22 Sep 2026 21:38:41 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/182370.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 24 May 2007 11:45:46 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to byteweise manipulation von &amp;quot;größeren&amp;quot; variablen on Thu, 24 May 2007 11:45:46 GMT]]></title><description><![CDATA[<p>Hi</p>
<p>wie macht man es in C/C++ ich byteweise variablen manipuliere?</p>
<p>hier mal ein beispiel.</p>
<pre><code class="language-cpp">#include &quot;stdafx.h&quot;
#include &lt;stdio.h&gt;

int _tmain(int argc, _TCHAR* argv[])
{
	unsigned char high=0x12;
	unsigned char low=0x34;
	unsigned short int ausgabe=0x0000;
	//
	//...Code?
	//
	printf(&quot;zahl ist %x&quot;,ausgabe);
	getchar();

	return 0;
}
</code></pre>
<p>die ausgabe soll dann &quot;zahl ist 1234&quot; sein. ich könnte das auch mit mathematische operationen machen, aber ich sehe es nicht ein die resourcen zu verschwenden wenn ich es auch byteweise machen kann.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1291356</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1291356</guid><dc:creator><![CDATA[xlomx]]></dc:creator><pubDate>Thu, 24 May 2007 11:45:46 GMT</pubDate></item><item><title><![CDATA[Reply to byteweise manipulation von &amp;quot;größeren&amp;quot; variablen on Thu, 24 May 2007 11:49:21 GMT]]></title><description><![CDATA[<p>Ich würde vermutlich mit Bit-Shift's und Kombinationen arbeiten: <code>ausgabe=high&lt;&lt;8 | low;</code> - damit bist du eigentlich auf der sicheren Seite.</p>
<p>(im Notfall hilf vielleicht auch ein reinterpret_cast an der richtigen Stelle, aber das dürfte alles andere als portabel sein)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1291358</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1291358</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Thu, 24 May 2007 11:49:21 GMT</pubDate></item><item><title><![CDATA[Reply to byteweise manipulation von &amp;quot;größeren&amp;quot; variablen on Thu, 24 May 2007 12:38:54 GMT]]></title><description><![CDATA[<p>gibt es keine standart-C möglichkeit mit der man direkt auf die bytes zugreifen kann?</p>
<p>was ist wenn ich demnächst 4 byte eines floats einzeln bekomme? zum beispiel in eine unsigned char array? könnte auch noch passieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1291391</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1291391</guid><dc:creator><![CDATA[xlomx]]></dc:creator><pubDate>Thu, 24 May 2007 12:38:54 GMT</pubDate></item><item><title><![CDATA[Reply to byteweise manipulation von &amp;quot;größeren&amp;quot; variablen on Thu, 24 May 2007 12:43:26 GMT]]></title><description><![CDATA[<p>Im Standard ist nichtmal festgelegt, in welcher Reihenfolge die Bytes betrachtet werden, aber auf eigene Gefahr: <code>char*c=reinterpret_cast&lt;char*&gt;(&amp;ausgabe)</code> .</p>
<p>(aber um damit etwas sinnvolles machen zu können, mußt du dich sehr gut auskennen)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1291393</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1291393</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Thu, 24 May 2007 12:43:26 GMT</pubDate></item><item><title><![CDATA[Reply to byteweise manipulation von &amp;quot;größeren&amp;quot; variablen on Thu, 24 May 2007 14:05:01 GMT]]></title><description><![CDATA[<p>müsste klappen, short int sollte überall 16bit sein, ist ja halt so definiert.</p>
<p>geht das reinterpret_cast auch in GCC?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1291435</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1291435</guid><dc:creator><![CDATA[xlomx]]></dc:creator><pubDate>Thu, 24 May 2007 14:05:01 GMT</pubDate></item><item><title><![CDATA[Reply to byteweise manipulation von &amp;quot;größeren&amp;quot; variablen on Thu, 24 May 2007 14:23:59 GMT]]></title><description><![CDATA[<p>xlomx schrieb:</p>
<blockquote>
<p>müsste klappen, short int sollte überall 16bit sein, ist ja halt so definiert.</p>
<p>geht das reinterpret_cast auch in GCC?</p>
</blockquote>
<p>ja</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1291443</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1291443</guid><dc:creator><![CDATA[Checker*amp*Murckser]]></dc:creator><pubDate>Thu, 24 May 2007 14:23:59 GMT</pubDate></item><item><title><![CDATA[Reply to byteweise manipulation von &amp;quot;größeren&amp;quot; variablen on Thu, 24 May 2007 14:25:43 GMT]]></title><description><![CDATA[<p>xlomx schrieb:</p>
<blockquote>
<p>müsste klappen, short int sollte überall 16bit sein, ist ja halt so definiert.</p>
<p>geht das reinterpret_cast auch in GCC?</p>
</blockquote>
<p>ja</p>
<p>/Edit: ach verflucht, jetzt kam die 2 mal, bitte eine löschen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1291446</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1291446</guid><dc:creator><![CDATA[Checker*amp*Murckser]]></dc:creator><pubDate>Thu, 24 May 2007 14:25:43 GMT</pubDate></item><item><title><![CDATA[Reply to byteweise manipulation von &amp;quot;größeren&amp;quot; variablen on Thu, 24 May 2007 14:37:25 GMT]]></title><description><![CDATA[<p>xlomx schrieb:</p>
<blockquote>
<p>müsste klappen, short int sollte überall 16bit sein, ist ja halt so definiert.</p>
</blockquote>
<p>Es ist festgelegt, daß short <strong>mindestens</strong> 16 Bit hat - nach oben ist die Größe offen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1291457</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1291457</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Thu, 24 May 2007 14:37:25 GMT</pubDate></item><item><title><![CDATA[Reply to byteweise manipulation von &amp;quot;größeren&amp;quot; variablen on Thu, 24 May 2007 15:09:55 GMT]]></title><description><![CDATA[<p>Die Diskussion hatte ich schon öfter und ich dachte das wäre erledigt.<br />
Hatte mich mit mir selbst darauf geeinigt, das gilt:<br />
sizeof(char) &lt;= sizeof(short) &lt;= sizeof(int) ..</p>
<p>Also muss short nicht mindestens 16 Bit sein. oder?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1291484</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1291484</guid><dc:creator><![CDATA[templäd]]></dc:creator><pubDate>Thu, 24 May 2007 15:09:55 GMT</pubDate></item><item><title><![CDATA[Reply to byteweise manipulation von &amp;quot;größeren&amp;quot; variablen on Thu, 24 May 2007 15:14:05 GMT]]></title><description><![CDATA[<p>Außer diesen Größenverhältnissen definiert der Standard auch Mindestwerte für die entsprechenden Wertebereiche - z.B. für short von 32000 (müßte ich nachsehen). Und daraus ergibt sich natürlich auch eine Minimalgröße <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1291487</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1291487</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Thu, 24 May 2007 15:14:05 GMT</pubDate></item><item><title><![CDATA[Reply to byteweise manipulation von &amp;quot;größeren&amp;quot; variablen on Thu, 24 May 2007 15:20:48 GMT]]></title><description><![CDATA[<p>standard schrieb:</p>
<blockquote>
<p>Plain ints have the natural<br />
size suggested by the architecture of the execution environment</p>
</blockquote>
<p>und</p>
<p>standard schrieb:</p>
<blockquote>
<p>that is, large enough to contain any value in the range of INT_MIN and INT_MAX, as defined in the header &lt;climits&gt;.</p>
</blockquote>
<p>Damit ist ja eine gewisse Mindestgroesse vorgegeben.</p>
<p>gruss<br />
v R</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1291494</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1291494</guid><dc:creator><![CDATA[virtuell Realisticer]]></dc:creator><pubDate>Thu, 24 May 2007 15:20:48 GMT</pubDate></item><item><title><![CDATA[Reply to byteweise manipulation von &amp;quot;größeren&amp;quot; variablen on Thu, 24 May 2007 15:22:42 GMT]]></title><description><![CDATA[<p>nagut, dann muss ich es vorher abfragen.<br />
das mit den mindestgrößen nervt. ich brauche genau definierte größen. zumindest 8, 16 und 32 bit.<br />
<img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<p>ich habe das so verstanden das int die gleiche länge hat wie der adressbus und der rest ist definiert, aber man lernt nie aus</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1291497</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1291497</guid><dc:creator><![CDATA[xlomx]]></dc:creator><pubDate>Thu, 24 May 2007 15:22:42 GMT</pubDate></item><item><title><![CDATA[Reply to byteweise manipulation von &amp;quot;größeren&amp;quot; variablen on Thu, 24 May 2007 15:24:28 GMT]]></title><description><![CDATA[<p>Du koenntest z. b. boost::uint8_t, boost::uint16_t und boost::uint32_t nutzen.<br />
Dafuer muss du auch nicht gegen eine Boost-Lib linken.</p>
<p>gruss<br />
v R</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1291498</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1291498</guid><dc:creator><![CDATA[virtuell Realisticer]]></dc:creator><pubDate>Thu, 24 May 2007 15:24:28 GMT</pubDate></item><item><title><![CDATA[Reply to byteweise manipulation von &amp;quot;größeren&amp;quot; variablen on Fri, 25 May 2007 08:26:13 GMT]]></title><description><![CDATA[<p>gut werde das so machen.</p>
<p>das problem ist eigendlich nur, ich benutze das auch in einem µC und da soll ja alles möglichs efficient sein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1291999</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1291999</guid><dc:creator><![CDATA[xlomx]]></dc:creator><pubDate>Fri, 25 May 2007 08:26:13 GMT</pubDate></item><item><title><![CDATA[Reply to byteweise manipulation von &amp;quot;größeren&amp;quot; variablen on Fri, 25 May 2007 08:46:00 GMT]]></title><description><![CDATA[<p>xlomx schrieb:</p>
<blockquote>
<p>gut werde das so machen.</p>
<p>das problem ist eigendlich nur, ich benutze das auch in einem µC und da soll ja alles möglichs efficient sein.</p>
</blockquote>
<p>Wenn du die Boost-Lib benutzt, wird garantiert, dass boost::uintXX_t auch<br />
tatsaechlich XX Bits breit ist.</p>
<p>Wenn du nicht die komplexen Boost-Includes nutzen willst, koenntest du dir<br />
zumindest ansehen, wie die das machen und es gerade uebernehmen.</p>
<p>gruss<br />
v R</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1292019</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1292019</guid><dc:creator><![CDATA[virtuell Realisticer]]></dc:creator><pubDate>Fri, 25 May 2007 08:46:00 GMT</pubDate></item></channel></rss>