<?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[Konvertierung mit _fcvt]]></title><description><![CDATA[<p>Hihi,</p>
<p>ich konvertiere double-Wert immer mit folgendem Code:</p>
<pre><code>//Konvertierung von double in CString

    strTmp = _fcvt(wert, 3, &amp;decimal, &amp;sign);
    strInt = strTmp.Left(decimal);     //beinhaltet integer vor dem Komma
    strDecimal = strTmp.Mid(decimal);  //beinhaltet alles nach dem Komma

    if (strInt.IsEmpty())
    {
        strInt = '0';
    }

    CString m_strwert;

    m_strwert.Format (&quot;%s.%s&quot;,strInt,strDecimal);
</code></pre>
<p>Nun habe ich aber zwei Probleme.</p>
<p>Erstens verliere ich das Minuszeichen. OK, dies kann ich abfangen in dem ich kontrolliere ob der double-Wert kleiner Null ist und ggf. ein Minuszeichen vor den String klebe. Das lässt sich also lösen.</p>
<p>Mein zweites Problem ist gravierender. Habe ich kleine Wert, z.B. 0.00258 und will den konvertieren, dann steht in strInt nichts -&gt; daraus setzte ich 0. in strDecimal steht komischerweise 3 drin. in decimal steht -2. wie kommt dass?<br />
und wie kann ich das beheben. irgendwie wäre wünschenswert, wenn in m_strDecimal 003 drinsteht.</p>
<p>Notfalls müsste ich die nullen auffüllen, aber das ist doch keine schöne lösung.</p>
<p>ihr habt bestimmt eine viel bessere idee.</p>
<p>danke</p>
<p>liebe Grüße</p>
<p>Andrea</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/157504/konvertierung-mit-_fcvt</link><generator>RSS for Node</generator><lastBuildDate>Sun, 26 Jul 2026 15:09:29 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/157504.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 26 Aug 2006 15:55:50 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Konvertierung mit _fcvt on Sat, 26 Aug 2006 15:55:50 GMT]]></title><description><![CDATA[<p>Hihi,</p>
<p>ich konvertiere double-Wert immer mit folgendem Code:</p>
<pre><code>//Konvertierung von double in CString

    strTmp = _fcvt(wert, 3, &amp;decimal, &amp;sign);
    strInt = strTmp.Left(decimal);     //beinhaltet integer vor dem Komma
    strDecimal = strTmp.Mid(decimal);  //beinhaltet alles nach dem Komma

    if (strInt.IsEmpty())
    {
        strInt = '0';
    }

    CString m_strwert;

    m_strwert.Format (&quot;%s.%s&quot;,strInt,strDecimal);
</code></pre>
<p>Nun habe ich aber zwei Probleme.</p>
<p>Erstens verliere ich das Minuszeichen. OK, dies kann ich abfangen in dem ich kontrolliere ob der double-Wert kleiner Null ist und ggf. ein Minuszeichen vor den String klebe. Das lässt sich also lösen.</p>
<p>Mein zweites Problem ist gravierender. Habe ich kleine Wert, z.B. 0.00258 und will den konvertieren, dann steht in strInt nichts -&gt; daraus setzte ich 0. in strDecimal steht komischerweise 3 drin. in decimal steht -2. wie kommt dass?<br />
und wie kann ich das beheben. irgendwie wäre wünschenswert, wenn in m_strDecimal 003 drinsteht.</p>
<p>Notfalls müsste ich die nullen auffüllen, aber das ist doch keine schöne lösung.</p>
<p>ihr habt bestimmt eine viel bessere idee.</p>
<p>danke</p>
<p>liebe Grüße</p>
<p>Andrea</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1124989</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1124989</guid><dc:creator><![CDATA[andrea19791]]></dc:creator><pubDate>Sat, 26 Aug 2006 15:55:50 GMT</pubDate></item><item><title><![CDATA[Reply to Konvertierung mit _fcvt on Sat, 26 Aug 2006 16:01:34 GMT]]></title><description><![CDATA[<p>andrea19791 schrieb:</p>
<blockquote>
<p>ihr habt bestimmt eine viel bessere idee.</p>
</blockquote>
<p>nimm doch 'CString::Format()'</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1124994</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1124994</guid><dc:creator><![CDATA[net 0]]></dc:creator><pubDate>Sat, 26 Aug 2006 16:01:34 GMT</pubDate></item><item><title><![CDATA[Reply to Konvertierung mit _fcvt on Sat, 26 Aug 2006 16:32:13 GMT]]></title><description><![CDATA[<p>wie soll das funktionieren? ich will doch einen double umwandeln.</p>
<p>schreib mal noch ein wenig genauer.</p>
<p>danke</p>
<p>andrea</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1125018</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1125018</guid><dc:creator><![CDATA[andrea19791]]></dc:creator><pubDate>Sat, 26 Aug 2006 16:32:13 GMT</pubDate></item><item><title><![CDATA[Reply to Konvertierung mit _fcvt on Sat, 26 Aug 2006 16:41:34 GMT]]></title><description><![CDATA[<p>andrea19791 schrieb:</p>
<blockquote>
<p>wie soll das funktionieren? ich will doch einen double umwandeln.</p>
</blockquote>
<p>willst du nicht aus 'nem double ein CString machen?<br />
also wenn ich dich nicht falsch verstehe...</p>
<pre><code>CString s;
   double d = 123.45678;
   s.Format (&quot;%lf&quot;, d);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1125024</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1125024</guid><dc:creator><![CDATA[net 0]]></dc:creator><pubDate>Sat, 26 Aug 2006 16:41:34 GMT</pubDate></item><item><title><![CDATA[Reply to Konvertierung mit _fcvt on Sat, 26 Aug 2006 17:02:12 GMT]]></title><description><![CDATA[<p>oh, sorry du hast ja schon recht. kann ich auch irgendwie steuern, wieviele nachkommastellen mitgenommen werden?</p>
<p>liebe grüße<br />
Andrea</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1125045</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1125045</guid><dc:creator><![CDATA[andrea19791]]></dc:creator><pubDate>Sat, 26 Aug 2006 17:02:12 GMT</pubDate></item><item><title><![CDATA[Reply to Konvertierung mit _fcvt on Sat, 26 Aug 2006 17:08:03 GMT]]></title><description><![CDATA[<p>andrea19791 schrieb:</p>
<blockquote>
<p>oh, sorry du hast ja schon recht. kann ich auch irgendwie steuern, wieviele nachkommastellen mitgenommen werden?</p>
</blockquote>
<p>klar geht das:</p>
<pre><code>s.Format (&quot;%.39lf&quot;, d);  // 39 nachkommastellen ;)
</code></pre>
<p>wenn du's variabel haben willst musste den formatstring selber formatieren, ebenfalls mit CString::Format()...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1125049</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1125049</guid><dc:creator><![CDATA[net 0]]></dc:creator><pubDate>Sat, 26 Aug 2006 17:08:03 GMT</pubDate></item><item><title><![CDATA[Reply to Konvertierung mit _fcvt on Sat, 26 Aug 2006 17:21:48 GMT]]></title><description><![CDATA[<p>vielen dank,</p>
<p>da habe ich bisher wohl ein wenig umständlich programmiert.</p>
<p>vielen herzlichen dank</p>
<p>liebe grüße</p>
<p>andrea</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1125059</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1125059</guid><dc:creator><![CDATA[andrea19791]]></dc:creator><pubDate>Sat, 26 Aug 2006 17:21:48 GMT</pubDate></item></channel></rss>