<?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[Dezimal Zahl -&amp;gt; Bytes]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich kriege von meinem LPT Port beim Abfragen eine Zahl z.B. 90 ausgegeben, nun würde ich gerne eine Funktion schreiben die mir ausgibt aus welchen Bytes sie besteht, also hier aus: 64+16+8+2.</p>
<p>Gibt es dafür eine Funktion etc.<br />
Oder muss man das selber schreiben, wenn ja wie, ich finde irgendwie keinen Ansatz dafür.</p>
<p>Mfg. BNS</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/174419/dezimal-zahl-gt-bytes</link><generator>RSS for Node</generator><lastBuildDate>Fri, 14 Aug 2026 21:43:55 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/174419.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 26 Feb 2007 18:36:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Dezimal Zahl -&amp;gt; Bytes on Mon, 26 Feb 2007 18:36:39 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich kriege von meinem LPT Port beim Abfragen eine Zahl z.B. 90 ausgegeben, nun würde ich gerne eine Funktion schreiben die mir ausgibt aus welchen Bytes sie besteht, also hier aus: 64+16+8+2.</p>
<p>Gibt es dafür eine Funktion etc.<br />
Oder muss man das selber schreiben, wenn ja wie, ich finde irgendwie keinen Ansatz dafür.</p>
<p>Mfg. BNS</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1235944</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1235944</guid><dc:creator><![CDATA[BNightSpeeder]]></dc:creator><pubDate>Mon, 26 Feb 2007 18:36:39 GMT</pubDate></item><item><title><![CDATA[Reply to Dezimal Zahl -&amp;gt; Bytes on Mon, 26 Feb 2007 18:40:47 GMT]]></title><description><![CDATA[<p>Anscheinend weißt du nicht was ein Byte ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1235949</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1235949</guid><dc:creator><![CDATA[Kenner, der]]></dc:creator><pubDate>Mon, 26 Feb 2007 18:40:47 GMT</pubDate></item><item><title><![CDATA[Reply to Dezimal Zahl -&amp;gt; Bytes on Mon, 26 Feb 2007 18:49:41 GMT]]></title><description><![CDATA[<p>Schätze er meint die Wertigkeit der einzelnen Bits.<br />
Die 90 von oben wäre also Binär 1011010</p>
<pre><code>1| 0| 1| 1| 0| 1| 0
64|32|16| 8| 4| 2| 1
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1235961</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1235961</guid><dc:creator><![CDATA[der_andi]]></dc:creator><pubDate>Mon, 26 Feb 2007 18:49:41 GMT</pubDate></item><item><title><![CDATA[Reply to Dezimal Zahl -&amp;gt; Bytes on Mon, 26 Feb 2007 18:59:59 GMT]]></title><description><![CDATA[<p>Hab es wohl Falsch formuliert ich will wenn ich die Zahl 90 habe eine Ausgabe von:<br />
64<br />
16<br />
8<br />
2<br />
bekommen ohne tausende von Schleifen und if Befehlen zu machen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1235970</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1235970</guid><dc:creator><![CDATA[BNightSpeeder]]></dc:creator><pubDate>Mon, 26 Feb 2007 18:59:59 GMT</pubDate></item><item><title><![CDATA[Reply to Dezimal Zahl -&amp;gt; Bytes on Mon, 26 Feb 2007 19:42:50 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>Na dann würd ich doch mal Modulo- (Rest-) Berechnung vorschlagen<br />
(90%64 = 26) = 1<br />
(26%32 = 26 (ungültig)) = 0<br />
(26%16 = 10) = 1<br />
usw...</p>
<p>da kannst dir sogar ne schleife 'drumrumbauen'</p>
<p>mfg, Micha</p>
<p>//Edit: Er meint schon Byte, aber dann müsste es so aussehen: 01011010</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1235983</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1235983</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Mon, 26 Feb 2007 19:42:50 GMT</pubDate></item><item><title><![CDATA[Reply to Dezimal Zahl -&amp;gt; Bytes on Mon, 26 Feb 2007 20:02:26 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">unsigned bit = 0x80000000; // für sizeof(unsigned) == 4
do {
    if(bit &amp; meineZahl)
        std::cout &lt;&lt; bit &lt;&lt; std::endl;
} while(bit &gt;&gt;= 1);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1236002</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1236002</guid><dc:creator><![CDATA[Entenwickler wieder da]]></dc:creator><pubDate>Mon, 26 Feb 2007 20:02:26 GMT</pubDate></item><item><title><![CDATA[Reply to Dezimal Zahl -&amp;gt; Bytes on Tue, 27 Feb 2007 14:47:47 GMT]]></title><description><![CDATA[<p>Ok ich habe aber ein Problem:</p>
<pre><code class="language-cpp">if (90 % 64 == 1) {
//
}
</code></pre>
<p>es passier aber nicht auch bei 0;false;true;1 oder 26 nicht, also ich verstehe nicht ganz wie man das machen muss mit Modulo.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1236227</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1236227</guid><dc:creator><![CDATA[BNightSpeeder]]></dc:creator><pubDate>Tue, 27 Feb 2007 14:47:47 GMT</pubDate></item><item><title><![CDATA[Reply to Dezimal Zahl -&amp;gt; Bytes on Tue, 27 Feb 2007 15:23:13 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>du musst eigentlich nur überprüfen ob der Berechnungswert mit dem Anfangswert übereinstimmt.</p>
<p>Also:</p>
<pre><code class="language-cpp">int d_start = 90, new_d_start, b_wert = 128;

for (int i = 0; i &lt; 8; i++)
{
        new_d_start = d_start % b_wert;
        if (new_d_start != d_start)
        {
                ListBox1-&gt;Items-&gt;Add(b_wert); //Ausgabe 64, 16...                
                d_start = new_d_start;
                // Label1-&gt;Caption = Label1-&gt;Caption + &quot;1&quot;; &lt;&lt; Binärausgabe

        }
        else
        {
                // Label1-&gt;Caption = Label1-&gt;Caption + &quot;0&quot;; &lt;&lt; Binärausgabe
        }
        b_wert = b_wert / 2;
}
</code></pre>
<p>mfg, Micha</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1236242</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1236242</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Tue, 27 Feb 2007 15:23:13 GMT</pubDate></item><item><title><![CDATA[Reply to Dezimal Zahl -&amp;gt; Bytes on Thu, 01 Mar 2007 19:30:35 GMT]]></title><description><![CDATA[<p>HI, ich habe anstatt eine ListBox es so gemacht:</p>
<pre><code class="language-cpp">if (Byte1 &gt;= 255) {
                                d_start = 255;
                        }
                        if (Byte1 &lt;= 128 &amp;&amp; Byte1 &gt; 64) {
                                d_start = 128;
                        }
                        if (Byte1 &lt;= 64 &amp;&amp; Byte1 &gt; 32) {
                                d_start = 64;
                        }
                        if (Byte1 &lt;= 32 &amp;&amp; Byte1 &gt; 16) {
                                d_start = 32;
                        }
                        if (Byte1 &lt;= 16 &amp;&amp; Byte1 &gt; 8) {
                                d_start = 16;
                        }
                        if (Byte1 &lt;= 8 &amp;&amp; Byte1 &gt; 4) {
                                d_start = 8;
                        }
                        if (Byte1 &lt;= 4 &amp;&amp; Byte1 &gt; 2) {
                                d_start = 4;
                        }
                        if (Byte1 &lt;= 2 &amp;&amp; Byte1 &gt; 1) {
                                d_start = 2;
                        }

                for (int i = 0; i &lt; 8; i++){
                        new_d_start = d_start % b_wert;

                        if (new_d_start != d_start) {
                                switch (b_wert) {
                                        case 1: Button1-&gt;Click(); break;
                                        case 2: Button2-&gt;Click(); break;
                                        case 4: Button3-&gt;Click(); break;
                                        case 8: Button4-&gt;Click(); break;
                                        case 16: Button5-&gt;Click(); break;
                                        case 32: Button6-&gt;Click(); break;
                                        case 64: Button7-&gt;Click(); break;
                                        case 128: Button8-&gt;Click(); break;
                                }
                                d_start = new_d_start;
                                // Label1-&gt;Caption = Label1-&gt;Caption + &quot;1&quot;; &lt;&lt; Binärausgabe

                        }
                        else {
                        // Label1-&gt;Caption = Label1-&gt;Caption + &quot;0&quot;; &lt;&lt; Binärausgabe
                        }

                        b_wert = b_wert / 2;
                }
</code></pre>
<p>Die Buttons etc. ist alles richtig doch er macht mir jedes mal falsche Buttons an egal bei welchem Code.<br />
Wo liegt der Fehler?</p>
<p>Mfg. BNS</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1237677</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1237677</guid><dc:creator><![CDATA[BNightSpeeder]]></dc:creator><pubDate>Thu, 01 Mar 2007 19:30:35 GMT</pubDate></item><item><title><![CDATA[Reply to Dezimal Zahl -&amp;gt; Bytes on Thu, 01 Mar 2007 19:52:01 GMT]]></title><description><![CDATA[<p>Hi,</p>
<pre><code class="language-cpp">int d_start = 90, new_d_start, b_wert = 128, Byte1 = 22;

if (Byte1 &gt;= 255) {
                                d_start = 255;
                        }
                        if (Byte1 &lt;= 128 &amp;&amp; Byte1 &gt; 64) {
                                d_start = 128;
                        }
                        if (Byte1 &lt;= 64 &amp;&amp; Byte1 &gt; 32) {
                                d_start = 64;
                        }
                        if (Byte1 &lt;= 32 &amp;&amp; Byte1 &gt; 16) {
                                d_start = 32;
                        } 
                        if (Byte1 &lt;= 16 &amp;&amp; Byte1 &gt; 8) {
                                d_start = 16;
                        } 
                        if (Byte1 &lt;= 8 &amp;&amp; Byte1 &gt; 4) {
                                d_start = 8;
                        }
                        if (Byte1 &lt;= 4 &amp;&amp; Byte1 &gt; 2) {
                                d_start = 4;
                        }
                        if (Byte1 &lt;= 2 &amp;&amp; Byte1 &gt; 1) { 
                                d_start = 2;
                        }

for (int i = 0; i &lt; 8; i++)
{
        new_d_start = d_start % b_wert; 
        if (new_d_start != d_start)
        {
                switch(b_wert)
                {
                        case 1: ShowMessage(&quot;1&quot;); break;
                        case 2: ShowMessage(&quot;2&quot;); break;
                        case 4: ShowMessage(&quot;4&quot;); break;
                        case 8: ShowMessage(&quot;8&quot;); break;
                        case 16: ShowMessage(&quot;16&quot;); break;
                        case 32: ShowMessage(&quot;32&quot;); break;
                        case 64: ShowMessage(&quot;64&quot;); break;
                        case 128: ShowMessage(&quot;128&quot;); break;
                }
                d_start = new_d_start;
                // Label1-&gt;Caption = Label1-&gt;Caption + &quot;1&quot;; &lt;&lt; Binärausgabe 

        } 
        else 
        { 
                // Label1-&gt;Caption = Label1-&gt;Caption + &quot;0&quot;; &lt;&lt; Binärausgabe 
        }
        b_wert = b_wert / 2;
}
</code></pre>
<p>Also das funktioniert bei mir, wenn ich zum Beispiel 22 als Byte1 eingebe zeigt er mir am Ende 32 an ... also das passt schon!</p>
<p>Die Funktionsweise an sich ist aber verkehrt, weil 22 setzt sich aus 16, 4 und 2 zusammen! Deswegen versteh ich deine Routine nicht ganz.</p>
<p>Ich würde einfach abkürzen auf:</p>
<pre><code class="language-cpp">int d_start = 90, new_d_start, b_wert = 128, Byte1 = 22;

if (Byte1 &gt; 255) 
{
        d_start = 255;
}

for (int i = 0; i &lt; 8; i++)
{
        new_d_start = d_start % b_wert; 
        if (new_d_start != d_start)
        {
                switch(b_wert)
                {
                        case 1: ShowMessage(&quot;1&quot;); break;
                        case 2: ShowMessage(&quot;2&quot;); break;
                        case 4: ShowMessage(&quot;4&quot;); break;
                        case 8: ShowMessage(&quot;8&quot;); break;
                        case 16: ShowMessage(&quot;16&quot;); break;
                        case 32: ShowMessage(&quot;32&quot;); break;
                        case 64: ShowMessage(&quot;64&quot;); break;
                        case 128: ShowMessage(&quot;128&quot;); break;
                }
                d_start = new_d_start;
                // Label1-&gt;Caption = Label1-&gt;Caption + &quot;1&quot;; &lt;&lt; Binärausgabe 

        } 
        else 
        { 
                // Label1-&gt;Caption = Label1-&gt;Caption + &quot;0&quot;; &lt;&lt; Binärausgabe 
        }
        b_wert = b_wert / 2;
}
</code></pre>
<p>Alles kleiner/gleich 255 setzt sich sowieso aus 128,64,32,16,8,4,2,1 zusammen.</p>
<p>mfg, Micha</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1237715</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1237715</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Thu, 01 Mar 2007 19:52:01 GMT</pubDate></item><item><title><![CDATA[Reply to Dezimal Zahl -&amp;gt; Bytes on Thu, 01 Mar 2007 20:09:34 GMT]]></title><description><![CDATA[<p>ok, vielen danke es funktioniert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1237728</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1237728</guid><dc:creator><![CDATA[BNightSpeeder]]></dc:creator><pubDate>Thu, 01 Mar 2007 20:09:34 GMT</pubDate></item></channel></rss>