<?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[int to bytes]]></title><description><![CDATA[<p>Hi!</p>
<p>Ich wollte ein unsigned int in vier unsigned char's haben.<br />
Da hab ich das gefunden:</p>
<pre><code>byte1 = deinInteger &amp; 0xFF;
byte2 = deinInteger&gt;&gt;8 &amp; 0xFF;
byte2 = deinInteger&gt;&gt;16 &amp; 0xFF;
byte2 = deinInteger&gt;&gt;24 &amp; 0xFF;
</code></pre>
<p>Aber geht das nicht auch SO:</p>
<pre><code>byte1 = deinInteger &amp; 0x000000FF;
byte2 = deinInteger &amp; 0x0000FF00;
byte2 = deinInteger &amp; 0x00FF0000;
byte2 = deinInteger &amp; 0xFF000000;
</code></pre>
<p>Was wäre denn daran falsch?<br />
Und gibt es Unterschiede bei int/unsigned int und char/unsigned char?</p>
<p>Und dazu noch eine Frage:<br />
Bleibt das Ergebnis solcher Bitoperatoren immer gleich, wenn man es unter Windows ausführt?<br />
Ist es egal, ob das 32bit (x86?) kompilierte Programm auf einem x86, x86-64, x64, amd64, IA64 oder sonstwo läuft?</p>
<p>Danke schonmal!</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/246682/int-to-bytes</link><generator>RSS for Node</generator><lastBuildDate>Fri, 18 Sep 2026 01:42:02 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/246682.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 31 Jul 2009 08:58:26 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to int to bytes on Fri, 31 Jul 2009 08:58:26 GMT]]></title><description><![CDATA[<p>Hi!</p>
<p>Ich wollte ein unsigned int in vier unsigned char's haben.<br />
Da hab ich das gefunden:</p>
<pre><code>byte1 = deinInteger &amp; 0xFF;
byte2 = deinInteger&gt;&gt;8 &amp; 0xFF;
byte2 = deinInteger&gt;&gt;16 &amp; 0xFF;
byte2 = deinInteger&gt;&gt;24 &amp; 0xFF;
</code></pre>
<p>Aber geht das nicht auch SO:</p>
<pre><code>byte1 = deinInteger &amp; 0x000000FF;
byte2 = deinInteger &amp; 0x0000FF00;
byte2 = deinInteger &amp; 0x00FF0000;
byte2 = deinInteger &amp; 0xFF000000;
</code></pre>
<p>Was wäre denn daran falsch?<br />
Und gibt es Unterschiede bei int/unsigned int und char/unsigned char?</p>
<p>Und dazu noch eine Frage:<br />
Bleibt das Ergebnis solcher Bitoperatoren immer gleich, wenn man es unter Windows ausführt?<br />
Ist es egal, ob das 32bit (x86?) kompilierte Programm auf einem x86, x86-64, x64, amd64, IA64 oder sonstwo läuft?</p>
<p>Danke schonmal!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1752804</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1752804</guid><dc:creator><![CDATA[Convert0r]]></dc:creator><pubDate>Fri, 31 Jul 2009 08:58:26 GMT</pubDate></item><item><title><![CDATA[Reply to int to bytes on Fri, 31 Jul 2009 09:15:28 GMT]]></title><description><![CDATA[<blockquote>
<p>Was wäre denn daran falsch?<br />
Und gibt es Unterschiede bei int/unsigned int und char/unsigned char?</p>
</blockquote>
<p>Google doch mal danach...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1752818</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1752818</guid><dc:creator><![CDATA[theta]]></dc:creator><pubDate>Fri, 31 Jul 2009 09:15:28 GMT</pubDate></item><item><title><![CDATA[Reply to int to bytes on Fri, 31 Jul 2009 09:22:37 GMT]]></title><description><![CDATA[<p>Habe ich. Bin vllt. zu dumm.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1752822</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1752822</guid><dc:creator><![CDATA[Convert0r]]></dc:creator><pubDate>Fri, 31 Jul 2009 09:22:37 GMT</pubDate></item><item><title><![CDATA[Reply to int to bytes on Fri, 31 Jul 2009 09:24:00 GMT]]></title><description><![CDATA[<p>Convert0r schrieb:</p>
<blockquote>
<p>Aber geht das nicht auch SO:</p>
<pre><code>byte1 = deinInteger &amp; 0x000000FF;
byte2 = deinInteger &amp; 0x0000FF00;
byte2 = deinInteger &amp; 0x00FF0000;
byte2 = deinInteger &amp; 0xFF000000;
</code></pre>
</blockquote>
<p>Nein, damit löscht Du nur Bits und byte2 bis byte4 werden zu 0. Außerdem denke ich dass du noch einen cast brauchst sonst beschwert sich der Compiler</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1752825</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1752825</guid><dc:creator><![CDATA[general bacardi]]></dc:creator><pubDate>Fri, 31 Jul 2009 09:24:00 GMT</pubDate></item><item><title><![CDATA[Reply to int to bytes on Fri, 31 Jul 2009 09:28:16 GMT]]></title><description><![CDATA[<p>Achsoooo ich Dumpfbacke, verstehe schon.<br />
Es werden nur die niederwertigsten Bits kopiert (Bis auf die Größe der Variable, zu der zugewiesen wird), neh?</p>
<p>Bleibt noch die Frage zu signed/unsigned und die letzte Frage.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1752827</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1752827</guid><dc:creator><![CDATA[Convert0r]]></dc:creator><pubDate>Fri, 31 Jul 2009 09:28:16 GMT</pubDate></item></channel></rss>