<?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[Hexadezimal nach float konvertieren (IEEE format)]]></title><description><![CDATA[<p>Ich habe zum Thema IEEE in der suche 4 Themen gefunden, nur leider gehen sie an dem vorbei was ich brauche.</p>
<p>Ich habe eine Hex-Zahl <strong>3F0E5604</strong><br />
Die ist dezimal (laut anderer Software) <strong>0.5559999942779541</strong></p>
<p>Hier meine Quelle:<br />
<a href="http://babbage.cs.qc.edu/courses/cs341/IEEE-754hex32.html" rel="nofollow">http://babbage.cs.qc.edu/courses/cs341/IEEE-754hex32.html</a></p>
<p>Ich weiß nur nicht wie ich auf den Wert komme.<br />
Ich brauche eine c/c++ Funktion mit der ich das umrechnen kann.</p>
<p>Kann mir wer helfen?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/154658/hexadezimal-nach-float-konvertieren-ieee-format</link><generator>RSS for Node</generator><lastBuildDate>Tue, 08 Sep 2026 00:32:41 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/154658.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 29 Jul 2006 09:42:51 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Hexadezimal nach float konvertieren (IEEE format) on Sat, 29 Jul 2006 09:43:16 GMT]]></title><description><![CDATA[<p>Ich habe zum Thema IEEE in der suche 4 Themen gefunden, nur leider gehen sie an dem vorbei was ich brauche.</p>
<p>Ich habe eine Hex-Zahl <strong>3F0E5604</strong><br />
Die ist dezimal (laut anderer Software) <strong>0.5559999942779541</strong></p>
<p>Hier meine Quelle:<br />
<a href="http://babbage.cs.qc.edu/courses/cs341/IEEE-754hex32.html" rel="nofollow">http://babbage.cs.qc.edu/courses/cs341/IEEE-754hex32.html</a></p>
<p>Ich weiß nur nicht wie ich auf den Wert komme.<br />
Ich brauche eine c/c++ Funktion mit der ich das umrechnen kann.</p>
<p>Kann mir wer helfen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1106532</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1106532</guid><dc:creator><![CDATA[haedfinger]]></dc:creator><pubDate>Sat, 29 Jul 2006 09:43:16 GMT</pubDate></item><item><title><![CDATA[Reply to Hexadezimal nach float konvertieren (IEEE format) on Sat, 29 Jul 2006 13:38:19 GMT]]></title><description><![CDATA[<p>Schau dir doch 'mal den HTML (bzw. JavaScript) Code der Seite an, deren Link du gepostet hast <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>Greetz, Swordfish</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1106683</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1106683</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Sat, 29 Jul 2006 13:38:19 GMT</pubDate></item><item><title><![CDATA[Reply to Hexadezimal nach float konvertieren (IEEE format) on Sat, 29 Jul 2006 13:39:41 GMT]]></title><description><![CDATA[<p>Hier ein kleines Beispiel wie du es ohne großen Aufwand machen kannst.<br />
Achtung der reinterpret_cast ist ein sehr gefährliches aber<br />
auch ein sehr nützliches Werkszeug.</p>
<pre><code class="language-cpp">int hexval = 0x3F0E5604;
float* val = reinterpret_cast&lt;float*&gt;(&amp;hexval);
std::cout &lt;&lt; std::setprecision(10) &lt;&lt; *val &lt;&lt; std::endl;
</code></pre>
<p>Ich hoffe das hilft dir ein wenig.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1106684</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1106684</guid><dc:creator><![CDATA[Viper190]]></dc:creator><pubDate>Sat, 29 Jul 2006 13:39:41 GMT</pubDate></item><item><title><![CDATA[Reply to Hexadezimal nach float konvertieren (IEEE format) on Sat, 29 Jul 2006 14:54:14 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/10587">@Viper190</a>: wohl eher:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;

using namespace std;

int main( )
{
    unsigned int hexval = 0x3F0E5604;
    float *val = reinterpret_cast&lt; float* &gt;( &amp;hexval );
    cout.precision( 10 );  // &lt;-- !!
    cout &lt;&lt; *val &lt;&lt; endl;
}
</code></pre>
<p>Ach ja, warum ist <em>reinterpret_cast&lt; &gt;</em> gefährlich?</p>
<p>Greetz, Swordfish</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1106722</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1106722</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Sat, 29 Jul 2006 14:54:14 GMT</pubDate></item><item><title><![CDATA[Reply to Hexadezimal nach float konvertieren (IEEE format) on Sat, 29 Jul 2006 14:59:53 GMT]]></title><description><![CDATA[<p>Oha...<br />
Wenn ich ehrlich bin würde ich mir den Quellcode nur kopieren und hoffen das es stimmt, da ich ihn leider nicht ganz verstehe.</p>
<p>Zuden habe ich derzeit den HexWert nur in einer CString Variablen</p>
<p>CString sHexWert.</p>
<p>Könntet ihr mir nochmal ein Beispiel machen wie ich von dem CString auf meine floatzahl komme?</p>
<p>Ich danke eu vorab schonmal recht herzlich.<br />
Auch für die schon geleisteten Posts <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/1106730</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1106730</guid><dc:creator><![CDATA[haedfinger]]></dc:creator><pubDate>Sat, 29 Jul 2006 14:59:53 GMT</pubDate></item><item><title><![CDATA[Reply to Hexadezimal nach float konvertieren (IEEE format) on Sat, 29 Jul 2006 15:01:11 GMT]]></title><description><![CDATA[<p>Swordfish schrieb:</p>
<blockquote>
<p>Ach ja, warum ist <em>reinterpret_cast&lt; &gt;</em> gefährlich?</p>
</blockquote>
<p>Weil er nicht plattformunabhängig ist und vorallem nicht auf die größe achtet. Beispiel:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;

int main()
{
    int a = 0x3F0E5604;
    std::cout &lt;&lt; *reinterpret_cast&lt;double*&gt;(&amp;a) &lt;&lt; std::endl;
}
</code></pre>
<p>Double ist meistens 8 Byte groß und int nur 4. Also haben wir hier einen Zugriff auf 4 Byte die hinter a liegen, die evtl. uninitialisiert sind -&gt; undefiniertes Verhalten. (oder auch Zugriffsverletzung)</p>
<p>Erkennst du auch daran, dass das Programm immer ne andere Ausgabe hat (zu mindestens bei mir).</p>
<p>mfg.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1106732</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1106732</guid><dc:creator><![CDATA[joomoo]]></dc:creator><pubDate>Sat, 29 Jul 2006 15:01:11 GMT</pubDate></item><item><title><![CDATA[Reply to Hexadezimal nach float konvertieren (IEEE format) on Sat, 29 Jul 2006 15:26:31 GMT]]></title><description><![CDATA[<p>Ich kann deinem Post joomoo nur zustimmen.<br />
Vielen Dank das du das für mich beantwortet hast.</p>
<p>Deswegen habe ich in meinem Beispiel oben einen</p>
<pre><code class="language-cpp">float
</code></pre>
<p>benutzt.<br />
Dann ist die Ausgabe konstant da kein nicht initialisierter Speicher<br />
vorhanden ist.</p>
<p>Gruß<br />
Viper190</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1106737</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1106737</guid><dc:creator><![CDATA[Viper190]]></dc:creator><pubDate>Sat, 29 Jul 2006 15:26:31 GMT</pubDate></item><item><title><![CDATA[Reply to Hexadezimal nach float konvertieren (IEEE format) on Sat, 29 Jul 2006 15:41:04 GMT]]></title><description><![CDATA[<p>Für dein ganzes Problem habe ich dir folgenden Code geschrieben.<br />
ich arbeite hier allerdings mit einem std::string (std::basic_string).<br />
Du musst halt deinen CString noch zu einem std::string bringen.<br />
(Sorry habe hier keine CString zu verfügung)</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;sstream&gt;
#include &lt;iomanip&gt;

template &lt;class T&gt;
bool from_string(T&amp; t, 
                 const std::string&amp; s, 
                 std::ios_base&amp; (*f)(std::ios_base&amp;))
{
  std::istringstream iss(s);
  return !(iss &gt;&gt; f &gt;&gt; t).fail();
}

int main(int argc, char* argv[])
{

	int intValue;
	from_string&lt;int&gt;(intValue, std::string(&quot;3F0E5604&quot;), std::hex);
	float *val = reinterpret_cast&lt; float* &gt;( &amp;intValue );
	std::cout &lt;&lt; std::setprecision(10) &lt;&lt; *val &lt;&lt; std::endl;
	return 0;
}
</code></pre>
<p>Gruß<br />
Viper 190</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1106748</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1106748</guid><dc:creator><![CDATA[Viper190]]></dc:creator><pubDate>Sat, 29 Jul 2006 15:41:04 GMT</pubDate></item><item><title><![CDATA[Reply to Hexadezimal nach float konvertieren (IEEE format) on Sat, 29 Jul 2006 15:42:10 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/6950">@Joomoo</a> &amp; Viper190: Ist mir schon klar. Ich würde einen <em>reinterpret_cast&lt; &gt;</em> jedoch desswegen nicht mit <em>gefährlich</em> attributieren. Man sollte bloß wissen, was man macht.</p>
<p>Greetz, Swordfish</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1106749</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1106749</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Sat, 29 Jul 2006 15:42:10 GMT</pubDate></item><item><title><![CDATA[Reply to Hexadezimal nach float konvertieren (IEEE format) on Sat, 29 Jul 2006 15:44:12 GMT]]></title><description><![CDATA[<p>Vielleicht war gefährlich von mir ein wenig falsch gewählt.<br />
Sorry wollte deswegen jetzt keine Diskussion anfangen.</p>
<p>Ja man muss halt wissen was man mach <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>cheers</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1106751</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1106751</guid><dc:creator><![CDATA[Viper190]]></dc:creator><pubDate>Sat, 29 Jul 2006 15:44:12 GMT</pubDate></item><item><title><![CDATA[Reply to Hexadezimal nach float konvertieren (IEEE format) on Sat, 29 Jul 2006 16:12:32 GMT]]></title><description><![CDATA[<p>Vielen dank! Ich teste es gleich <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/1106772</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1106772</guid><dc:creator><![CDATA[haedfinger]]></dc:creator><pubDate>Sat, 29 Jul 2006 16:12:32 GMT</pubDate></item><item><title><![CDATA[Reply to Hexadezimal nach float konvertieren (IEEE format) on Sun, 30 Jul 2006 11:08:48 GMT]]></title><description><![CDATA[<p>Viper190 schrieb:</p>
<blockquote>
<p>Für dein ganzes Problem habe ich dir folgenden Code geschrieben.<br />
ich arbeite hier allerdings mit einem std::string (std::basic_string).<br />
Du musst halt deinen CString noch zu einem std::string bringen.<br />
(Sorry habe hier keine CString zu verfügung)</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;sstream&gt;
#include &lt;iomanip&gt;

template &lt;class T&gt;
bool from_string(T&amp; t, 
                 const std::string&amp; s, 
                 std::ios_base&amp; (*f)(std::ios_base&amp;))
{
  std::istringstream iss(s);
  return !(iss &gt;&gt; f &gt;&gt; t).fail();
}

int main(int argc, char* argv[])
{
	
	int intValue;
	from_string&lt;int&gt;(intValue, std::string(&quot;3F0E5604&quot;), std::hex);
	float *val = reinterpret_cast&lt; float* &gt;( &amp;intValue );
	std::cout &lt;&lt; std::setprecision(10) &lt;&lt; *val &lt;&lt; std::endl;
	return 0;
}
</code></pre>
<p>Gruß<br />
Viper 190</p>
</blockquote>
<p>Joa super!!<br />
So geht es... ABER ^^</p>
<p>Wie zum Geier wandle ich mein CString zu einem std::string.<br />
Bekomme ich nicht gebacken <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
<p>-------------- EDIT --------------<br />
Sorry habe versucht ne falsch Variable zu übergeben ^^</p>
<p>so geht es</p>
<pre><code class="language-cpp">/* Hex in float wndeln */
	CString sNutzDaten = &quot;3F0E5604&quot;;

    from_string&lt;int&gt;(intValue, LPCTSTR(sNutzDaten), std::hex);
    float *val = reinterpret_cast&lt; float* &gt;( &amp;intValue );
    std::cout &lt;&lt; std::setprecision(10) &lt;&lt; *val &lt;&lt; std::endl;

	/* Ausgabe in einer EditBox */
	sNutzDaten.Format(&quot;%.3f&quot;,*val);
	GetDlgItem(IDC_LAST_RECIVED_STRING)-&gt;SetWindowText(sNutzDaten);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1107050</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1107050</guid><dc:creator><![CDATA[haedfinger]]></dc:creator><pubDate>Sun, 30 Jul 2006 11:08:48 GMT</pubDate></item><item><title><![CDATA[Reply to Hexadezimal nach float konvertieren (IEEE format) on Sun, 30 Jul 2006 11:27:07 GMT]]></title><description><![CDATA[<p>Bei mir funktioniert</p>
<pre><code class="language-cpp">#include &lt;string&gt;
#include &lt;iostream&gt;

#include &lt;atlstr.h&gt;

using namespace std;

int main( )
{
    CString cs = &quot;Hello&quot;;
    string str;

    str = cs;

    cout &lt;&lt; str &lt;&lt; endl;
}
</code></pre>
<p>tadellos. Somit müsste der Aufruf von</p>
<p>headfinger schrieb:</p>
<blockquote>
<pre><code class="language-cpp">from_string&lt; int &gt;( intValue, LPCTSTR( sNutzDaten ), std::hex );
</code></pre>
</blockquote>
<p>auch ohne dem Cast von <em>sNutzDaten</em> zu <em>LPCTSTR</em> funktionieren.</p>
<p>Greetz, Swordfish</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1107072</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1107072</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Sun, 30 Jul 2006 11:27:07 GMT</pubDate></item><item><title><![CDATA[Reply to Hexadezimal nach float konvertieren (IEEE format) on Sun, 30 Jul 2006 11:33:57 GMT]]></title><description><![CDATA[<p>Irgendwie ist die Frage doch etwas sinnlos. Wenn man 'nen float im Rechner abspeichert, dann ist er doch im IEEE Format. Was gibts da noch zu konvertieren? Die sauberste Methode um sowas dann als anderen Typ zu lesen oder gar zu schreiben ist IMHO eine union. Da sorgt der Compiler dafür, das man keinen Speicher benutzt der einem nicht gehört. f'`8k</p>
<p>Gruß, TGGC (<a href="http://www.games-net.de/hosted/tggc" rel="nofollow">\-/ returns</a>)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1107077</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1107077</guid><dc:creator><![CDATA[TGGC]]></dc:creator><pubDate>Sun, 30 Jul 2006 11:33:57 GMT</pubDate></item><item><title><![CDATA[Reply to Hexadezimal nach float konvertieren (IEEE format) on Sun, 30 Jul 2006 11:41:56 GMT]]></title><description><![CDATA[<p>@TGGGC:</p>
<p>meinst du so:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;

using namespace std;

union IEEE_float_converter_t {

    float f;
    unsigned int i;
};

int main( )
{
    IEEE_float_converter_t ieeefc;
    ieeefc.i = 0x3F0E5604;

    cout &lt;&lt; hex &lt;&lt; ieeefc.i &lt;&lt; &quot; entspricht &quot;;

    cout.precision( 10 );
    cout &lt;&lt; ieeefc.f &lt;&lt; endl;
}
</code></pre>
<p>oder?</p>
<p>Greetz, Swordfish</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1107083</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1107083</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Sun, 30 Jul 2006 11:41:56 GMT</pubDate></item><item><title><![CDATA[Reply to Hexadezimal nach float konvertieren (IEEE format) on Sun, 30 Jul 2006 11:51:14 GMT]]></title><description><![CDATA[<p>und wie wärs damit? man müsste sich natürlich noch ein bisschen gedanken um die byte-reihenfolge machen - muss man aber mit int auch.</p>
<pre><code class="language-cpp">union IEEE_float_converter_t 
{	
    float f;
    unsigned char c[sizeof(float)];
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1107090</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1107090</guid><dc:creator><![CDATA[lustig_sizeof_benutze]]></dc:creator><pubDate>Sun, 30 Jul 2006 11:51:14 GMT</pubDate></item><item><title><![CDATA[Reply to Hexadezimal nach float konvertieren (IEEE format) on Sun, 30 Jul 2006 15:16:56 GMT]]></title><description><![CDATA[<p>Wie genau, das hängt davon ab, was man erreichen will. So genau definiert das die Frage überhaupt nicht. f'`8k</p>
<p>Gruß, TGGC (<a href="http://www.games-net.de/hosted/tggc" rel="nofollow">\-/ returns</a>)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1107175</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1107175</guid><dc:creator><![CDATA[TGGC]]></dc:creator><pubDate>Sun, 30 Jul 2006 15:16:56 GMT</pubDate></item><item><title><![CDATA[Reply to Hexadezimal nach float konvertieren (IEEE format) on Sun, 30 Jul 2006 14:31:58 GMT]]></title><description><![CDATA[<p>Ach TGGC, sei nicht immer so kleinlich. Wenn du es nur <em>ungefähr</em> so gemeint hast, wie hast du es dann <em>exakt</em> gemeint?</p>
<p>Greetz, Swordfish</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1107182</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1107182</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Sun, 30 Jul 2006 14:31:58 GMT</pubDate></item></channel></rss>