<?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[Kommastelle um  3 Stellen verschieben (ganz schnell)]]></title><description><![CDATA[<p>Hallo,<br />
ich suche eine Möglichkeit, effektiv eine Kommastelle (vom Double) zuverschieben.<br />
Mit 1000 multiplizieren, ist eine Möglichkeit ,aber gibt es noch was Schnelleres? Weil das ganz soll viele Millionen mal geschehen. gibt es da ein Bitshift-Trick oder etwas Ähnliches.<br />
genau genommen soll das gemacht werden:</p>
<pre><code class="language-cpp">int I;
double D; 
D=I;    
D*=0.001;

/*..Rechnen mit D...*/

D*=1000;
I=D;
</code></pre>
<p>please help... danke</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/252984/kommastelle-um-3-stellen-verschieben-ganz-schnell</link><generator>RSS for Node</generator><lastBuildDate>Sat, 30 May 2026 18:34:05 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/252984.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 27 Oct 2009 10:38:23 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Kommastelle um  3 Stellen verschieben (ganz schnell) on Tue, 27 Oct 2009 10:38:23 GMT]]></title><description><![CDATA[<p>Hallo,<br />
ich suche eine Möglichkeit, effektiv eine Kommastelle (vom Double) zuverschieben.<br />
Mit 1000 multiplizieren, ist eine Möglichkeit ,aber gibt es noch was Schnelleres? Weil das ganz soll viele Millionen mal geschehen. gibt es da ein Bitshift-Trick oder etwas Ähnliches.<br />
genau genommen soll das gemacht werden:</p>
<pre><code class="language-cpp">int I;
double D; 
D=I;    
D*=0.001;

/*..Rechnen mit D...*/

D*=1000;
I=D;
</code></pre>
<p>please help... danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1798987</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1798987</guid><dc:creator><![CDATA[BILL]]></dc:creator><pubDate>Tue, 27 Oct 2009 10:38:23 GMT</pubDate></item><item><title><![CDATA[Reply to Kommastelle um  3 Stellen verschieben (ganz schnell) on Tue, 27 Oct 2009 10:42:05 GMT]]></title><description><![CDATA[<blockquote>
<p>Mit 1000 multiplizieren, ist eine Möglichkeit ,aber gibt es noch was Schnelleres?</p>
</blockquote>
<p>Nein, ich glaube nicht. Schon mal ueber Vektorisierung nachgedacht?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1798993</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1798993</guid><dc:creator><![CDATA[knivil]]></dc:creator><pubDate>Tue, 27 Oct 2009 10:42:05 GMT</pubDate></item><item><title><![CDATA[Reply to Kommastelle um  3 Stellen verschieben (ganz schnell) on Tue, 27 Oct 2009 11:41:59 GMT]]></title><description><![CDATA[<p>Wenn es nicht gerade 1000 sein muss, sondern auch 1024 sein darf, dann müsste das (selbst mit doubles) schneller gehen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1799031</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1799031</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Tue, 27 Oct 2009 11:41:59 GMT</pubDate></item><item><title><![CDATA[Reply to Kommastelle um  3 Stellen verschieben (ganz schnell) on Tue, 27 Oct 2009 11:53:59 GMT]]></title><description><![CDATA[<p>Für das Problem &quot;Komma in Dezimaldarstellung drei Stellen nach links verschieben&quot; wird es wohl kaum eine schnellere Lösung als Multiplikation mit 1000 geben. Wenn du uns allerdings verrätst, was du vorhast, könnte man an deinem allgemeinen Vorgehen evtl. noch was verbessern. Kommaverschiebung, noch dazu millionenfach, klingt vom numerischen Standpunkt her nämlich nach einer ziemlich sinnlosen Aktion, deshalb frage ich mich, wozu das gut sein soll.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1799047</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1799047</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Tue, 27 Oct 2009 11:53:59 GMT</pubDate></item><item><title><![CDATA[Reply to Kommastelle um  3 Stellen verschieben (ganz schnell) on Tue, 27 Oct 2009 12:10:26 GMT]]></title><description><![CDATA[<blockquote>
<p>Wenn es nicht gerade 1000 sein muss, sondern auch 1024 sein darf,</p>
</blockquote>
<p>Ja, es darf auf etwas abweichen von 1000.<br />
Mittlerweile denke ich aber auch das es wohl nicht schneller geht als mit Multiplikation</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1799059</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1799059</guid><dc:creator><![CDATA[BILL]]></dc:creator><pubDate>Tue, 27 Oct 2009 12:10:26 GMT</pubDate></item><item><title><![CDATA[Reply to Kommastelle um  3 Stellen verschieben (ganz schnell) on Tue, 27 Oct 2009 12:38:04 GMT]]></title><description><![CDATA[<p>BILL schrieb:</p>
<blockquote>
<p>Ja, es darf auf etwas abweichen von 1000.<br />
Mittlerweile denke ich aber auch das es wohl nicht schneller geht als mit Multiplikation</p>
</blockquote>
<p>Ausprobieren. Ich würd's mal mit <a href="http://www.cplusplus.com/reference/clibrary/cmath/frexp/" rel="nofollow">frexp</a> und <a href="http://www.cplusplus.com/reference/clibrary/cmath/ldexp/" rel="nofollow">ldexp</a> probieren. Bei 'nem guten Compiler sind das schnelle <a href="http://en.wikipedia.org/wiki/Intrinsic_function" rel="nofollow">Intrinsics</a>.</p>
<pre><code class="language-cpp">double mit_1024_multiplizieren(double x)
{
  int exp;
  double d = std::frexp(x,&amp;exp);
  return std::ldexp(d,exp+10);
}
</code></pre>
<p>Gruß,<br />
SP</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1799075</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1799075</guid><dc:creator><![CDATA[Sebastian Pizer]]></dc:creator><pubDate>Tue, 27 Oct 2009 12:38:04 GMT</pubDate></item></channel></rss>