<?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[String to double -&amp;gt; mit Exponenten!]]></title><description><![CDATA[<p>hallo<br />
ich habe folgendes Problem:</p>
<p>ich habe einen String -&gt; &quot;1.1235464+e015&quot; diesen String möchte ich gern in ein double konvertieren. Ich habe es bis jetzt so gelöst :</p>
<pre><code class="language-cpp">double stringZuZahl(string s)
{
 stringstream sst;
 double temp;
 sst &lt;&lt; s;
 sst &gt;&gt; temp;
 return temp;
}
</code></pre>
<p>da ist aber das problem, dass diese Funktion ab dem &quot;+&quot; abschneidet. also kommt z.b. als double zahl folgendes herraus: 1.1235464</p>
<p>wenn ich also damit nun weiterrechnen will kommt natürlcih nicht das richtige Ergebnis heraus -&gt; da er nicht mit der richtigen Zahl rechnet.</p>
<p>Meine frage ist wie ich dieses Problem lösen kann -&gt; ich habe auch die Funktion atof() ausprobiert -&gt; selbes problem.</p>
<p>MFg</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/206012/string-to-double-gt-mit-exponenten</link><generator>RSS for Node</generator><lastBuildDate>Sat, 10 Oct 2026 01:00:30 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/206012.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 20 Feb 2008 12:54:21 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to String to double -&amp;gt; mit Exponenten! on Wed, 20 Feb 2008 12:54:21 GMT]]></title><description><![CDATA[<p>hallo<br />
ich habe folgendes Problem:</p>
<p>ich habe einen String -&gt; &quot;1.1235464+e015&quot; diesen String möchte ich gern in ein double konvertieren. Ich habe es bis jetzt so gelöst :</p>
<pre><code class="language-cpp">double stringZuZahl(string s)
{
 stringstream sst;
 double temp;
 sst &lt;&lt; s;
 sst &gt;&gt; temp;
 return temp;
}
</code></pre>
<p>da ist aber das problem, dass diese Funktion ab dem &quot;+&quot; abschneidet. also kommt z.b. als double zahl folgendes herraus: 1.1235464</p>
<p>wenn ich also damit nun weiterrechnen will kommt natürlcih nicht das richtige Ergebnis heraus -&gt; da er nicht mit der richtigen Zahl rechnet.</p>
<p>Meine frage ist wie ich dieses Problem lösen kann -&gt; ich habe auch die Funktion atof() ausprobiert -&gt; selbes problem.</p>
<p>MFg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1459397</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1459397</guid><dc:creator><![CDATA[Rainu]]></dc:creator><pubDate>Wed, 20 Feb 2008 12:54:21 GMT</pubDate></item><item><title><![CDATA[Reply to String to double -&amp;gt; mit Exponenten! on Wed, 20 Feb 2008 13:01:15 GMT]]></title><description><![CDATA[<p>indem du den String richtig formatierst: &quot;1.23464**e+**15&quot; Das was du da stehen hast ist ein double (1.23464) plus (+) irgendein Wust, den niemand so richtig entschluesseln kann (was soll &quot;e015&quot; bedeuten?)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1459402</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1459402</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Wed, 20 Feb 2008 13:01:15 GMT</pubDate></item><item><title><![CDATA[Reply to String to double -&amp;gt; mit Exponenten! on Wed, 20 Feb 2008 13:08:34 GMT]]></title><description><![CDATA[<p>ach na dann brauch ich mich net wundern <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61b.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_tongue"
      title=":P"
      alt="😛"
    /> -&gt; sorry aber trozdem THX ^^</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1459415</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1459415</guid><dc:creator><![CDATA[Rainu]]></dc:creator><pubDate>Wed, 20 Feb 2008 13:08:34 GMT</pubDate></item><item><title><![CDATA[Reply to String to double -&amp;gt; mit Exponenten! on Wed, 20 Feb 2008 13:38:32 GMT]]></title><description><![CDATA[<p>Und kopier nicht so oft unnötig!</p>
<pre><code class="language-cpp">double string_to_number(std::string const&amp; string) /* const-Ref. =&gt; Kopieren sparen! */
{
    std::istringstream ss(string); // direkt in Konstruktor packen. operator&lt;&lt; aufruf gespart!
    double tmp;
    ss &gt;&gt; tmp;
    return temp;
}
</code></pre>
<p><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="😉"
    /> Jetzt kanst du da auch ein Template draus amchen, damit es auch bei Integer usw. geht!</p>
<pre><code class="language-cpp">template&lt;typename destination_type&gt;
destination_type string_to_number(std::string const&amp; string)
{
    std::istringstream ss(string); 
    destination_type tmp;
    if (!(ss &gt;&gt; tmp)) throw std::bad_cast(&quot;no number&quot;);
    return temp;
}
</code></pre>
<p>so bekommst du sogar ne Exception um die Ohren, wenn du eine &quot;nicht Zahl&quot; eingibst <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/1459451</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1459451</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Wed, 20 Feb 2008 13:38:32 GMT</pubDate></item></channel></rss>