<?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[hex -&amp;gt; dez]]></title><description><![CDATA[<p>hy,<br />
gibt es ne vernünpftige standart-Möglichkeit, einen String, der eine Hex-Zahl enthält, in einen int umzuwandeln?<br />
Danke</p>
<p>PS: lexical_cast geht net <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>
]]></description><link>https://www.c-plusplus.net/forum/topic/177676/hex-gt-dez</link><generator>RSS for Node</generator><lastBuildDate>Wed, 23 Sep 2026 05:55:44 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/177676.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 02 Apr 2007 20:53:30 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to hex -&amp;gt; dez on Mon, 02 Apr 2007 20:53:30 GMT]]></title><description><![CDATA[<p>hy,<br />
gibt es ne vernünpftige standart-Möglichkeit, einen String, der eine Hex-Zahl enthält, in einen int umzuwandeln?<br />
Danke</p>
<p>PS: lexical_cast geht net <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>
]]></description><link>https://www.c-plusplus.net/forum/post/1258201</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1258201</guid><dc:creator><![CDATA[wiss0r]]></dc:creator><pubDate>Mon, 02 Apr 2007 20:53:30 GMT</pubDate></item><item><title><![CDATA[Reply to hex -&amp;gt; dez on Mon, 02 Apr 2007 21:08:18 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;string&gt;
#include &lt;sstream&gt;

int main()
{
using namespace std;
    string str(&quot;0x7ff&quot;);
    istringstream  istr(str);
    int a;
    istr &gt;&gt; hex &gt;&gt; a;
}
</code></pre>
<p>mfg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1258205</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1258205</guid><dc:creator><![CDATA[balduin]]></dc:creator><pubDate>Mon, 02 Apr 2007 21:08:18 GMT</pubDate></item><item><title><![CDATA[Reply to hex -&amp;gt; dez on Mon, 02 Apr 2007 21:09:41 GMT]]></title><description><![CDATA[<p>Ja, gibt es.<br />
Streams lassen sich da leicht manipulieren:</p>
<pre><code class="language-cpp">std::stringstream hexZahl;
hexZahl &lt;&lt; &quot;FF&quot;;
int zahl;
hexZahl &gt;&gt; std::hex &gt;&gt; zahl; // zahl enthält jetzt 255(in Dezimalansicht)
</code></pre>
<p>EDIT: zu spät...(20 sec *lol*)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1258206</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1258206</guid><dc:creator><![CDATA[Don06]]></dc:creator><pubDate>Mon, 02 Apr 2007 21:09:41 GMT</pubDate></item><item><title><![CDATA[Reply to hex -&amp;gt; dez on Tue, 05 Jun 2007 08:49:41 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>das Beispiel funktioniert perfekt.<br />
Aber gibt es die Möglichkeit auch für float, double?</p>
<p>Gruß Ross</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1299103</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1299103</guid><dc:creator><![CDATA[balduin]]></dc:creator><pubDate>Tue, 05 Jun 2007 08:49:41 GMT</pubDate></item><item><title><![CDATA[Reply to hex -&amp;gt; dez on Tue, 05 Jun 2007 09:03:08 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Eine float-Zahl in hex zu konvertieren ist doch irgendwie sinnlos. Wozu brauchst du den das?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1299114</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1299114</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Tue, 05 Jun 2007 09:03:08 GMT</pubDate></item><item><title><![CDATA[Reply to hex -&amp;gt; dez on Tue, 05 Jun 2007 09:06:31 GMT]]></title><description><![CDATA[<p>Ich habe eine Datei, in welcher in hex Messergebnisse gespeichert sind:<br />
z.B.: 0x40C4FE22<br />
Dies habe ich als String vorliegen und möchte das ganze nun als float haben.<br />
(Das ganze auch für double)</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1299116</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1299116</guid><dc:creator><![CDATA[balduin]]></dc:creator><pubDate>Tue, 05 Jun 2007 09:06:31 GMT</pubDate></item><item><title><![CDATA[Reply to hex -&amp;gt; dez on Tue, 05 Jun 2007 09:08:08 GMT]]></title><description><![CDATA[<p>balduin schrieb:</p>
<blockquote>
<p>Ich habe eine Datei, in welcher in hex Messergebnisse gespeichert sind:<br />
z.B.: 0x40C4FE22<br />
Dies habe ich als String vorliegen und möchte das ganze nun als float haben.<br />
(Das ganze auch für double)</p>
<p>Gruß</p>
</blockquote>
<p>(6.156022) wäre hier die Lösung</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1299118</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1299118</guid><dc:creator><![CDATA[balduin]]></dc:creator><pubDate>Tue, 05 Jun 2007 09:08:08 GMT</pubDate></item><item><title><![CDATA[Reply to hex -&amp;gt; dez on Tue, 05 Jun 2007 09:17:48 GMT]]></title><description><![CDATA[<p>balduin schrieb:</p>
<blockquote>
<p>balduin schrieb:</p>
<blockquote>
<p>Ich habe eine Datei, in welcher in hex Messergebnisse gespeichert sind:<br />
z.B.: 0x40C4FE22<br />
Dies habe ich als String vorliegen und möchte das ganze nun als float haben.<br />
(Das ganze auch für double)</p>
<p>Gruß</p>
</blockquote>
<p>(6.156022) wäre hier die Lösung</p>
</blockquote>
<p>Ähhhh Du sprichst jetzt aber nicht mehr von einer &quot;hex-&gt;dez&quot;-Umwandlung, sondern die Umdeutung einer internen Speicherrepräsentation, oder ?<br />
Da bietet der Standard natürlich nichst Generelles an ... aber wenn Du auf derselben Plattform arbeitest, kannst Du diese Bytes in einem char-Array ablegen und mittels reinterpret_cast umbiegen.... aber wie gesagt: Dazu muss die interne Darstellung übereinstimmen.</p>
<p>BTW: Welcher /&amp;=%&amp;&quot;*# kam denn auf die Idee, die floats direkt mit fwrite() wegzuschreiben ?</p>
<p>Gruß,</p>
<p>Simon2.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1299121</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1299121</guid><dc:creator><![CDATA[Simon2]]></dc:creator><pubDate>Tue, 05 Jun 2007 09:17:48 GMT</pubDate></item><item><title><![CDATA[Reply to hex -&amp;gt; dez on Tue, 05 Jun 2007 09:24:27 GMT]]></title><description><![CDATA[<p>Eigentlich will ich nur die selbe Operation wie hier:<br />
<a href="http://www.h-schmidt.net/FloatApplet/IEEE754de.html" rel="nofollow">http://www.h-schmidt.net/FloatApplet/IEEE754de.html</a><br />
durchführen.<br />
Also von der Hexadecimal representation in die Decimal representation wandeln.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1299127</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1299127</guid><dc:creator><![CDATA[balduin]]></dc:creator><pubDate>Tue, 05 Jun 2007 09:24:27 GMT</pubDate></item><item><title><![CDATA[Reply to hex -&amp;gt; dez on Tue, 05 Jun 2007 10:41:09 GMT]]></title><description><![CDATA[<p>balduin schrieb:</p>
<blockquote>
<p>Eigentlich will ich nur die selbe Operation wie hier:<br />
<a href="http://www.h-schmidt.net/FloatApplet/IEEE754de.html" rel="nofollow">http://www.h-schmidt.net/FloatApplet/IEEE754de.html</a><br />
durchführen.<br />
Also von der Hexadecimal representation in die Decimal representation wandeln.</p>
</blockquote>
<p>Habt ihr mein Problem soweit verstanden?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1299168</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1299168</guid><dc:creator><![CDATA[balduin]]></dc:creator><pubDate>Tue, 05 Jun 2007 10:41:09 GMT</pubDate></item><item><title><![CDATA[Reply to hex -&amp;gt; dez on Tue, 05 Jun 2007 10:46:17 GMT]]></title><description><![CDATA[<p>balduin schrieb:</p>
<blockquote>
<p>Habt ihr mein Problem soweit verstanden?</p>
</blockquote>
<p>Ja. Aber offenbar hast du Simon2s Lösung nicht verstanden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1299171</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1299171</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Tue, 05 Jun 2007 10:46:17 GMT</pubDate></item><item><title><![CDATA[Reply to hex -&amp;gt; dez on Tue, 05 Jun 2007 11:09:33 GMT]]></title><description><![CDATA[<p>balduin schrieb:</p>
<blockquote>
<p>Eigentlich will ich nur die selbe Operation wie hier:<br />
<a href="http://www.h-schmidt.net/FloatApplet/IEEE754de.html" rel="nofollow">http://www.h-schmidt.net/FloatApplet/IEEE754de.html</a><br />
durchführen.<br />
Also von der Hexadecimal representation in die Decimal representation wandeln.</p>
</blockquote>
<p>Hi,</p>
<blockquote>
<p>&quot; ...den von modernen CPUs verwendeten IEEE 754-Fließkommazahlen ...&quot;</p>
</blockquote>
<p>=&gt; direkte cast-Lösung funktioniert nur auf bestimmten Plattformen (auf nicht-IEEE-Plattformen eben nicht).</p>
<p>Insgesamt scheint es mir da für Dich deutlich einfacher, wenn Du den beschriebenen Umrechnungsalgorithmus umsetzt .... oder (IMO noch einfacher, falls möglich) ein simpleres Protokoll verwendest.</p>
<p>Gruß,</p>
<p>Simon2.</p>
<p>P.S.: Ich bin mir nicht ganz sicher, ob in o.g. Dokument bei 0 oder bei 1 angefangen wird zu zählen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1299183</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1299183</guid><dc:creator><![CDATA[Simon2]]></dc:creator><pubDate>Tue, 05 Jun 2007 11:09:33 GMT</pubDate></item><item><title><![CDATA[Reply to hex -&amp;gt; dez on Tue, 05 Jun 2007 11:07:06 GMT]]></title><description><![CDATA[<p>MFK schrieb:</p>
<blockquote>
<p>balduin schrieb:</p>
<blockquote>
<p>Habt ihr mein Problem soweit verstanden?</p>
</blockquote>
<p>Ja. Aber offenbar hast du Simon2s Lösung nicht verstanden.</p>
</blockquote>
<p>Ok, das bestreite ich nicht.<br />
Hat jemand einen Beispielcode?<br />
System: Win2000<br />
little endian format.<br />
Darstellung nach IEEE754 (single und double).</p>
<p>Als char Array habe ich alles schon vorliegen.</p>
<p>Danke für uere Hilfe.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1299187</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1299187</guid><dc:creator><![CDATA[balduin]]></dc:creator><pubDate>Tue, 05 Jun 2007 11:07:06 GMT</pubDate></item><item><title><![CDATA[Reply to hex -&amp;gt; dez on Tue, 05 Jun 2007 11:11:38 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">unsigned char a[] = &quot;\x93\x18\xec\x40&quot;;
   float* pf = reinterpret_cast&lt;float*&gt;(a);
   cout &lt;&lt; *pf &lt;&lt; &quot;\n&quot;;
</code></pre>
<p>Gruß,</p>
<p>Simon2.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1299192</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1299192</guid><dc:creator><![CDATA[Simon2]]></dc:creator><pubDate>Tue, 05 Jun 2007 11:11:38 GMT</pubDate></item><item><title><![CDATA[Reply to hex -&amp;gt; dez on Tue, 05 Jun 2007 11:16:44 GMT]]></title><description><![CDATA[<p>Simon2 schrieb:</p>
<blockquote>
<pre><code class="language-cpp">unsigned char a[] = &quot;\x93\x18\xec\x40&quot;;
   float* pf = reinterpret_cast&lt;float*&gt;(a);
   cout &lt;&lt; *pf &lt;&lt; &quot;\n&quot;;
</code></pre>
<p>Gruß,</p>
<p>Simon2.</p>
</blockquote>
<p>Danke Simon2<br />
Nun habe sogar ich verstanden wie das gemeint war und dabei ist heute nichteinmal Freitag <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/1299198</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1299198</guid><dc:creator><![CDATA[balduin]]></dc:creator><pubDate>Tue, 05 Jun 2007 11:16:44 GMT</pubDate></item><item><title><![CDATA[Reply to hex -&amp;gt; dez on Tue, 05 Jun 2007 11:19:15 GMT]]></title><description><![CDATA[<p>Bei float könnte man auch normal über int gehen.</p>
<pre><code class="language-cpp">// rausschreiben
    ofstream otest(&quot;Test.txt&quot;);
    float f = 20.5;
    int itemp = *(reinterpret_cast&lt;int*&gt;(&amp;f));
    otest &lt;&lt; hex &lt;&lt; itemp;
    otest.close();
// Einlesen
    ifstream itest(&quot;Test.txt&quot;);
    int iein;
    itest &gt;&gt; hex &gt;&gt; iein;
    float fein = *(reinterpret_cast&lt;float*&gt;(&amp;iein));
</code></pre>
<p>Bei double braucht man aber einen 64Bit-Ganzzahltypen (__int64 z.Bsp.)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1299200</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1299200</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Tue, 05 Jun 2007 11:19:15 GMT</pubDate></item><item><title><![CDATA[Reply to hex -&amp;gt; dez on Tue, 05 Jun 2007 11:27:16 GMT]]></title><description><![CDATA[<p>Also ich hab nicht geprüft, was die anderen hier vorschlagen.</p>
<p>Durchdenk das mal.</p>
<pre><code class="language-cpp">#include &lt;string&gt; 
#include &lt;sstream&gt; 
union f754
{
    int a;
    float b;
};
int main() 
{ 
using namespace std; 
    string str(&quot;0x7ff&quot;); 
    istringstream  istr(str); 
    f754 x; 
    istr &gt;&gt; hex &gt;&gt; x.a; 
    float result = x.b;
}
</code></pre>
<p>PS was double angeht, C++ kennt kein long long, bekommt man aber auch hin (halt double splitten).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1299207</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1299207</guid><dc:creator><![CDATA[der balduin vom 02.04.200]]></dc:creator><pubDate>Tue, 05 Jun 2007 11:27:16 GMT</pubDate></item></channel></rss>