<?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[bitshiften]]></title><description><![CDATA[<p>hallo alle zusammen,</p>
<p>#include&lt;iostream.h&gt;</p>
<p>void main()</p>
<p>{<br />
short a(16673),b(10);<br />
int c=((int)(a)&lt;&lt;16|(int)(b));<br />
float fc=<em>(float</em>)(&amp;c);</p>
<p>cout&lt;&lt;fc&lt;&lt;endl;<br />
}<br />
von diesem programm bekomme ich den wert 10.0625=fc gelifert!!<br />
wie komme ich von 10.0625=fc auf meine ursprünglichen werte<br />
a(16673),b(10); ????</p>
<p>h = (int (n)&lt;&lt;16 | (int)(c));</p>
<p>so bin ich wieder auf b=h gekommen.<br />
aber für a habe ich keine lösung<br />
thanx for help</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/123267/bitshiften</link><generator>RSS for Node</generator><lastBuildDate>Sun, 23 Aug 2026 13:04:52 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/123267.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 14 Oct 2005 13:23:56 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to bitshiften on Fri, 14 Oct 2005 13:23:56 GMT]]></title><description><![CDATA[<p>hallo alle zusammen,</p>
<p>#include&lt;iostream.h&gt;</p>
<p>void main()</p>
<p>{<br />
short a(16673),b(10);<br />
int c=((int)(a)&lt;&lt;16|(int)(b));<br />
float fc=<em>(float</em>)(&amp;c);</p>
<p>cout&lt;&lt;fc&lt;&lt;endl;<br />
}<br />
von diesem programm bekomme ich den wert 10.0625=fc gelifert!!<br />
wie komme ich von 10.0625=fc auf meine ursprünglichen werte<br />
a(16673),b(10); ????</p>
<p>h = (int (n)&lt;&lt;16 | (int)(c));</p>
<p>so bin ich wieder auf b=h gekommen.<br />
aber für a habe ich keine lösung<br />
thanx for help</p>
]]></description><link>https://www.c-plusplus.net/forum/post/892353</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/892353</guid><dc:creator><![CDATA[fubu16]]></dc:creator><pubDate>Fri, 14 Oct 2005 13:23:56 GMT</pubDate></item><item><title><![CDATA[Reply to bitshiften on Fri, 14 Oct 2005 13:29:27 GMT]]></title><description><![CDATA[<p>Man kann generell nicht sagen, dass durch zurückschieben, auch der alte Inhalt wieder hergestellt wird. Wenn du eins rausschiebst und schiebst zurück kommt ja ne 0 wieder rein, somit hat sich der Wert geändert</p>
]]></description><link>https://www.c-plusplus.net/forum/post/892355</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/892355</guid><dc:creator><![CDATA[Pellaeon]]></dc:creator><pubDate>Fri, 14 Oct 2005 13:29:27 GMT</pubDate></item><item><title><![CDATA[Reply to bitshiften on Sat, 15 Oct 2005 13:52:35 GMT]]></title><description><![CDATA[<p>Pellaeon schrieb:</p>
<blockquote>
<p>Man kann generell nicht sagen, dass durch zurückschieben, auch der alte Inhalt wieder hergestellt wird.</p>
</blockquote>
<p>Nö, es geht ja hier nicht darum, verworfene Daten wiederherzustellen.</p>
<p>fubu16 schrieb:</p>
<blockquote>
<p>wie komme ich von 10.0625=fc auf meine ursprünglichen werte</p>
</blockquote>
<p>Indem du deinen Algorithmus umkehrst. Was du momentan machst ist &lt;&lt; und |. Eine Umkehrung wäre demzufolge &amp; und &gt;&gt;.</p>
<pre><code class="language-cpp">short a(16673),b(10);
int c=((int)(a)&lt;&lt;16|(int)(b));
float fc=*(float*)(&amp;c);
//
int d = *reinterpret_cast&lt;int*&gt;(&amp;fc);
short b2 = static_cast&lt;short&gt;(d); // &amp; 0xffff brauchen wir nicht, da dies durch den Cast schon gemacht wird
short a2 = static_cast&lt;short&gt;(d &gt;&gt; 16);
</code></pre>
<p>noch einige Ergänzungen:<br />
- C++ legt Typgrössen nicht konkret fest, was du machst, muss also nicht überall funktionieren<br />
- shiften von negativen Werten ist implementationsspezifisch<br />
- VERWENDE BITTE AKTUELLES C++!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/892835</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/892835</guid><dc:creator><![CDATA[groovemaster]]></dc:creator><pubDate>Sat, 15 Oct 2005 13:52:35 GMT</pubDate></item></channel></rss>