<?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[Bin to Hex]]></title><description><![CDATA[<p>hallo zusammen ich hab in einer char zr[8]; eine binärzahl<br />
und möchte die in hex umwandel.. wie mach ich das mit BinToHex komm ich nicht klar.. sprich ich weiß ned genau was die funktion von mir erwartet..</p>
<pre><code class="language-cpp">char zr1[8],text[8]

if (cb11-&gt;Checked == true)
   {
   zr1[0] = 1;
   }
   else
   {
   zr1[0] = 0;
   }

if (cb12-&gt;Checked == true)
   {
   zr1[1] = 1;
   }
   else
   {
   zr1[1] = 0;
   }
if (cb13-&gt;Checked == true)
   {
   zr1[2] = 1;
   }
   else
   {
   zr1[2] = 0;
   }
if (cb14-&gt;Checked == true)
   {
   zr1[3] = 1;
   }
   else
   {
   zr1[3] = 0;
   }
if (cb15-&gt;Checked == true)
   {
   zr1[4] = 1;
   }
   else
   {
   zr1[4] = 0;
   }
if (cb16-&gt;Checked == true)
   {
   zr1[5] = 1;
   }
   else
   {
   zr1[5] = 0;
   }
if (cb17-&gt;Checked == true)
   {
   zr1[6] = 1;
   }
   else
   {
   zr1[6] = 0;
   }
if (cb18-&gt;Checked == true)
   {
   zr1[7] = 1;
   }
   else
   {
   zr1[7] = 0;
   }
BinToHex(zr1,text,2);

Edit1-&gt;Text = text;
</code></pre>
<p>mfg</p>
<p>|23|</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/88296/bin-to-hex</link><generator>RSS for Node</generator><lastBuildDate>Sun, 05 Jul 2026 03:22:51 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/88296.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 08 Oct 2004 09:51:21 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Bin to Hex on Fri, 08 Oct 2004 10:17:24 GMT]]></title><description><![CDATA[<p>hallo zusammen ich hab in einer char zr[8]; eine binärzahl<br />
und möchte die in hex umwandel.. wie mach ich das mit BinToHex komm ich nicht klar.. sprich ich weiß ned genau was die funktion von mir erwartet..</p>
<pre><code class="language-cpp">char zr1[8],text[8]

if (cb11-&gt;Checked == true)
   {
   zr1[0] = 1;
   }
   else
   {
   zr1[0] = 0;
   }

if (cb12-&gt;Checked == true)
   {
   zr1[1] = 1;
   }
   else
   {
   zr1[1] = 0;
   }
if (cb13-&gt;Checked == true)
   {
   zr1[2] = 1;
   }
   else
   {
   zr1[2] = 0;
   }
if (cb14-&gt;Checked == true)
   {
   zr1[3] = 1;
   }
   else
   {
   zr1[3] = 0;
   }
if (cb15-&gt;Checked == true)
   {
   zr1[4] = 1;
   }
   else
   {
   zr1[4] = 0;
   }
if (cb16-&gt;Checked == true)
   {
   zr1[5] = 1;
   }
   else
   {
   zr1[5] = 0;
   }
if (cb17-&gt;Checked == true)
   {
   zr1[6] = 1;
   }
   else
   {
   zr1[6] = 0;
   }
if (cb18-&gt;Checked == true)
   {
   zr1[7] = 1;
   }
   else
   {
   zr1[7] = 0;
   }
BinToHex(zr1,text,2);

Edit1-&gt;Text = text;
</code></pre>
<p>mfg</p>
<p>|23|</p>
]]></description><link>https://www.c-plusplus.net/forum/post/623902</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/623902</guid><dc:creator><![CDATA[*23*]]></dc:creator><pubDate>Fri, 08 Oct 2004 10:17:24 GMT</pubDate></item><item><title><![CDATA[Reply to Bin to Hex on Fri, 08 Oct 2004 12:30:42 GMT]]></title><description><![CDATA[<p>Hier ein kleines Beispiel zu <strong>BinToHex</strong>:</p>
<pre><code class="language-cpp">char bin[2];					// Platz für 2 Zeichen
char text[(sizeof(bin)*2)+1];	// Platz für 2 Hexzeichen + terminierende 0

// 2 Zeichen in Puffer schreiben
bin[0]='A';
bin[1]='B';
// Die 2 Zeichen im Puffer in Hex umwandeln
BinToHex(bin, text, 2);
// String Terminierung selber setzen, klappt nicht immer automatisch
// obwohl das in der Hilfe steht
*(text+(sizeof(bin)*2))=0;

// Ausgegeben wird der String  '4142'
ShowMessage(text);
</code></pre>
<p>Diese Funktion hat mich allerdings nicht vom Hocker gerissen, das Thema mit der abschließenden Null<br />
im Zielstring klappte hier nämlich überhaupt nicht. Bei diesem Beipiel stand immer brav eine Hex 01<br />
am Schluß des Strings.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/624017</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/624017</guid><dc:creator><![CDATA[Peter]]></dc:creator><pubDate>Fri, 08 Oct 2004 12:30:42 GMT</pubDate></item><item><title><![CDATA[Reply to Bin to Hex on Fri, 08 Oct 2004 19:08:57 GMT]]></title><description><![CDATA[<p>und erklär mir mal bitte wieso 01 bin = 4142 ist ??</p>
<p>hmm das ganze geht irgendwie nicht.. <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>hast auch nen Beispiel wie ich ein Int wer in eine Hexa zahl wandeln kann ??</p>
]]></description><link>https://www.c-plusplus.net/forum/post/624487</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/624487</guid><dc:creator><![CDATA[*23*]]></dc:creator><pubDate>Fri, 08 Oct 2004 19:08:57 GMT</pubDate></item><item><title><![CDATA[Reply to Bin to Hex on Fri, 08 Oct 2004 19:15:23 GMT]]></title><description><![CDATA[<p>|23| schrieb:</p>
<blockquote>
<p>und erklär mir mal bitte wieso 01 bin = 4142 ist ??</p>
<p>hmm das ganze geht irgendwie nicht.. <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>
</blockquote>
<pre><code class="language-cpp">// 2 Zeichen in Puffer schreiben
bin[0]='A';
bin[1]='B';
</code></pre>
<p>der ASCII-code für den Buchstaben A ist 41 und für B 42 und das in einem String gibt 4142</p>
<p>BigNeal</p>
]]></description><link>https://www.c-plusplus.net/forum/post/624492</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/624492</guid><dc:creator><![CDATA[BigNeal]]></dc:creator><pubDate>Fri, 08 Oct 2004 19:15:23 GMT</pubDate></item><item><title><![CDATA[Reply to Bin to Hex on Fri, 08 Oct 2004 20:31:59 GMT]]></title><description><![CDATA[<p>BigNeal schrieb:</p>
<blockquote>
<p>&lt;Edit: Zitate bitte auf das Notwendigste beschränken. Danke!&gt;</p>
</blockquote>
<p>Dann erreiche ich damit mein ZZiel auch nicht den ich brauch was,<br />
was mir aus z.b 10000101 = nen Hexa Zahl macht in diesen Fall ja: 85</p>
]]></description><link>https://www.c-plusplus.net/forum/post/624503</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/624503</guid><dc:creator><![CDATA[|23|logout]]></dc:creator><pubDate>Fri, 08 Oct 2004 20:31:59 GMT</pubDate></item><item><title><![CDATA[Reply to Bin to Hex on Fri, 08 Oct 2004 20:33:43 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">&lt;Edit: Zitate bitte auf das Notwendigste beschränken. Danke!&gt;
</code></pre>
<p>du kannst ja deine checkbox anstatt in ein chararray einfach alle in ein intwert reinschreiben, nicht einzeln in ein char.<br />
im Stil von:</p>
<pre><code class="language-cpp">int zrl;
if (cb11-&gt;Checked == true)
   {
   zr1 +=1;
   }
   zrl&lt;&lt;1;
if (cb12-&gt;Checked == true)
   {
   zr1 +=1;
   }
   zrl&lt;&lt;1;
etc..
ShowMessage(IntToHex(zrl,2));
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/624526</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/624526</guid><dc:creator><![CDATA[BigNeal]]></dc:creator><pubDate>Fri, 08 Oct 2004 20:33:43 GMT</pubDate></item><item><title><![CDATA[Reply to Bin to Hex on Sat, 09 Oct 2004 21:44:29 GMT]]></title><description><![CDATA[<p>Wenn ich mir Dein Programmfragment so ansehe, willst Du eine Binärzahl, dargestellt durch 8 Checkboxen (angekreuzt=1, nicht angekreuzt=0) in eine Hexzahl umwandeln und darstellen. Ich hab Dir mal ein kleines Beispiel gestrickt wie man sowas realisieren könnte. Mach einfach ein neues Projekt (leere Form) mit dem u.a. Code. Alles weiter macht das Programm automatisch.<br />
Wenn alles funktioniert, versuche den Programmcode nachzuvollziehen und zu verstehen.<br />
Du kannst natürlich auf die Routinen <strong>InitializeObjects / UninitializeObjects</strong> verzichten, alle Kompos von Hand auf der Form plazieren und die Tagwerte und die OnClick-Routine der Checkboxen im Objektinspektor einstellen.<br />
<strong>Keine Garantie auf Fehlerfreiheit</strong> <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>
<p><strong>.h Datei</strong></p>
<pre><code class="language-cpp">#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include &lt;Classes.hpp&gt;
#include &lt;Controls.hpp&gt;
#include &lt;StdCtrls.hpp&gt;
#include &lt;Forms.hpp&gt;
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:	// Von der IDE verwaltete Komponenten
private:	// Anwender-Deklarationen
	TObjectList *CheckBoxList;
	TEdit *EHex;
	TPanel *CheckBoxPanel;
	unsigned binval1;
	void __fastcall CheckBoxClick(TObject *Sender);
	void InitializeObjects(void);
	void UninitializeObjects(void);
	void ShowHexVal(TCheckBox *cb, TEdit *ed, unsigned &amp;binval);
public:		// Anwender-Deklarationen
	__fastcall TForm1(TComponent* Owner);
	__fastcall ~TForm1(void);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
</code></pre>
<p><strong>.cpp Datei</strong></p>
<pre><code class="language-cpp">#include &lt;vcl.h&gt;
#pragma hdrstop

#include &quot;Unit1.h&quot;
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource &quot;*.dfm&quot;
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner)
{
	InitializeObjects();
}
//---------------------------------------------------------------------------
__fastcall TForm1::~TForm1(void)
{
	UninitializeObjects();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::CheckBoxClick(TObject *Sender)
{
	ShowHexVal(static_cast&lt;TCheckBox*&gt;(Sender), EHex, binval1);
}
//---------------------------------------------------------------------------
void TForm1::UninitializeObjects(void)
{
	CheckBoxList-&gt;Clear();
}
//---------------------------------------------------------------------------
void TForm1::InitializeObjects(void)
{
	int x, tagwert;
	TCheckBox *cb;

	// Form initialisieren
	Position=poDesktopCenter;
	Width=400;
	Height=200;

	// &quot;Binärwert&quot; initialisieren, wird von den
	// Checkboxen entspr. angepasst
	binval1=0;

	// Panel zur Aufnahme der Eingabekomponenten
	CheckBoxPanel=new TPanel(this);
	CheckBoxPanel-&gt;Parent=this;
	CheckBoxPanel-&gt;Width=200;
	CheckBoxPanel-&gt;Height=100;
	CheckBoxPanel-&gt;Top=10;
	CheckBoxPanel-&gt;Left=(ClientWidth - CheckBoxPanel-&gt;Width) / 2;

	// Checkboxen zum Einstellen der Binärzahl
	CheckBoxList=new TObjectList(this);
	tagwert=1;
	for(x=7; x&gt;=0; x--)
	{	cb=new TCheckBox(this);
		cb-&gt;Parent=CheckBoxPanel;
		cb-&gt;Top=10;
		cb-&gt;Left=10+(x*23);
		cb-&gt;Width=20;
		cb-&gt;Caption=*NullStr;
		cb-&gt;Tag=tagwert;
		tagwert&lt;&lt;=1;
		cb-&gt;OnClick=CheckBoxClick;
		CheckBoxList-&gt;Add(cb);
	}

	// Editfeld zur Anzeige der Hexzahl
	EHex=new TEdit(this);
	EHex-&gt;Parent=CheckBoxPanel;
	EHex-&gt;Width=40;
	EHex-&gt;Top=50;
	EHex-&gt;Left=(CheckBoxPanel-&gt;Width - EHex-&gt;Width) / 2;
	EHex-&gt;ReadOnly=true;
}
//---------------------------------------------------------------------------
void TForm1::ShowHexVal(TCheckBox *cb, TEdit *ed, unsigned &amp;binval)
{
	if(cb-&gt;Checked)
		binval |= (unsigned)cb-&gt;Tag;
	else
		binval &amp;= ~(unsigned)cb-&gt;Tag;

	ed-&gt;Text=IntToHex((int)binval, 2);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/625139</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/625139</guid><dc:creator><![CDATA[Peter]]></dc:creator><pubDate>Sat, 09 Oct 2004 21:44:29 GMT</pubDate></item><item><title><![CDATA[Reply to Bin to Hex on Sun, 10 Oct 2004 11:11:21 GMT]]></title><description><![CDATA[<p>|23|,<br />
hier noch eine schlichte Alternative (halbherzig getestet):</p>
<pre><code class="language-cpp">char bin[8] = {0,0,0,0,1,0,1,0};
    char dec[8] = {128,64,32,16,8,4,2,1};

    int intVal = 0;
    for (int i = 0; i &lt; 8; i++)
    {
        intVal = intVal | (bin[i]*dec[i]);
    }
    String hexStr = IntToHex(intVal, 2);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/625272</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/625272</guid><dc:creator><![CDATA[dschensky]]></dc:creator><pubDate>Sun, 10 Oct 2004 11:11:21 GMT</pubDate></item><item><title><![CDATA[Reply to Bin to Hex on Mon, 11 Oct 2004 06:58:55 GMT]]></title><description><![CDATA[<p>...bin heute Nacht mit einem markerschütternden Schrei erwacht - irgend etwas war überhaupt nicht in Ordnung:<br />
[cpp] unsigned char dec[8] = {128,64,32,16,8,4,2,1};<br />
[/cpp]</p>
]]></description><link>https://www.c-plusplus.net/forum/post/625729</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/625729</guid><dc:creator><![CDATA[dschensky]]></dc:creator><pubDate>Mon, 11 Oct 2004 06:58:55 GMT</pubDate></item><item><title><![CDATA[Reply to Bin to Hex on Mon, 11 Oct 2004 07:26:27 GMT]]></title><description><![CDATA[<blockquote>
<p>bin heute Nacht mit einem markerschütternden Schrei erwacht ...</p>
</blockquote>
<p>Mir fallen solche Sachen meist dann ein, wenn ich im &quot;gekachelten Raum&quot; Platz genommen habe :D:D:D</p>
]]></description><link>https://www.c-plusplus.net/forum/post/625742</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/625742</guid><dc:creator><![CDATA[Peter]]></dc:creator><pubDate>Mon, 11 Oct 2004 07:26:27 GMT</pubDate></item><item><title><![CDATA[Reply to Bin to Hex on Tue, 12 Oct 2004 04:15:58 GMT]]></title><description><![CDATA[<p>ich hab die Lösung von dschensky mal noch etwas optimiert:</p>
<pre><code class="language-cpp">char bin[8] = {0,1,0,0,1,0,1,0};

    int intVal = 0;
    for (int i = 0; i &lt; 8; i++)
    {
        intVal &lt;&lt;= 1;
        intVal += bin[i];
    }
    String hexStr = IntToHex(intVal, 2);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/626569</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/626569</guid><dc:creator><![CDATA[Acidmrp]]></dc:creator><pubDate>Tue, 12 Oct 2004 04:15:58 GMT</pubDate></item></channel></rss>