<?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[[Gelöst] 33bit Zahl mit c&#x2F;c++]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>bin blutiger c/c++ Anfänger und suche eine Möglichkeit mit einer 33bit Zahl zu rechnen. Welchen Datentyp muss ich da nehmen und wie sage ich dem Compiler, dass er es mir richtig kompiliert?</p>
<p>Mit unsigned int, unsingen long, unsigned long int und unsigned long long funktioniert das irgendwie nicht. Da kommen dann manchmal negative Zahlen... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<p>g++ -o i i.c</p>
<p>Arbeite unter Linux mit &quot;gcc (GCC) 3.3.4 (pre 3.3.5 20040809)&quot; bzw. &quot;g++ (GCC) 3.3.4 (pre 3.3.5 20040809)&quot;</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/139609/gelöst-33bit-zahl-mit-c-c</link><generator>RSS for Node</generator><lastBuildDate>Sun, 30 Aug 2026 16:20:53 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/139609.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 07 Mar 2006 22:16:43 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [Gelöst] 33bit Zahl mit c&#x2F;c++ on Tue, 07 Mar 2006 22:58:54 GMT]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>bin blutiger c/c++ Anfänger und suche eine Möglichkeit mit einer 33bit Zahl zu rechnen. Welchen Datentyp muss ich da nehmen und wie sage ich dem Compiler, dass er es mir richtig kompiliert?</p>
<p>Mit unsigned int, unsingen long, unsigned long int und unsigned long long funktioniert das irgendwie nicht. Da kommen dann manchmal negative Zahlen... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<p>g++ -o i i.c</p>
<p>Arbeite unter Linux mit &quot;gcc (GCC) 3.3.4 (pre 3.3.5 20040809)&quot; bzw. &quot;g++ (GCC) 3.3.4 (pre 3.3.5 20040809)&quot;</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1011113</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1011113</guid><dc:creator><![CDATA[dmh]]></dc:creator><pubDate>Tue, 07 Mar 2006 22:58:54 GMT</pubDate></item><item><title><![CDATA[Reply to [Gelöst] 33bit Zahl mit c&#x2F;c++ on Tue, 07 Mar 2006 22:35:19 GMT]]></title><description><![CDATA[<p>int und long int sind in der regel gleich groß, beide 32-bit. int ist zwar nur als 16-bit garantiert, aber hat idr auch 32.</p>
<p>ganzahlige arithmetik für so grosse zahlen sind vielleicht in irgendeinem paket schon enthalten, weiss ich nicht.</p>
<p>wenn deine 33 bit zahlen nicht übermäßig groß werden, passen sie eventuell noch in unsigned int (bzw. long), das hat nen wertebereich von 0 - (2^32)-1.</p>
<p>ansonsten nimm irgendeinen fließkomma typ. float müsste eigentlich schon ausreichen. hat zwar auch nur 32 bit, durch die mantissen/exponenten darstellung lassen sich aber größere zahlen darstellen. double ist &quot;bisschen&quot; größer (64 bit) und long double ist geradezu riesig (80 bit).<br />
aber halt alles fließkomma darstellung</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1011128</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1011128</guid><dc:creator><![CDATA[camel filter]]></dc:creator><pubDate>Tue, 07 Mar 2006 22:35:19 GMT</pubDate></item><item><title><![CDATA[Reply to [Gelöst] 33bit Zahl mit c&#x2F;c++ on Tue, 07 Mar 2006 22:43:45 GMT]]></title><description><![CDATA[<p>Danke schon mal. Aber irgendwie geht das nicht. Mist.</p>
<p>Meine größte Zahl ist 8589934591. Muss also Werte von 0 bis 8589934591 speichern.</p>
<pre><code class="language-cpp">long double pts = 8589934591;

Konsole:
error: integer constant is too large for &quot;long&quot; type
</code></pre>
<p>Vielleicht noch irgendein Hinweis?!?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1011131</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1011131</guid><dc:creator><![CDATA[dmh]]></dc:creator><pubDate>Tue, 07 Mar 2006 22:43:45 GMT</pubDate></item><item><title><![CDATA[Reply to [Gelöst] 33bit Zahl mit c&#x2F;c++ on Tue, 07 Mar 2006 22:52:27 GMT]]></title><description><![CDATA[<p>Wenn ich nun</p>
<pre><code class="language-cpp">sizeof(unsigned long long)
</code></pre>
<p>mache, so kommt 8. Das heißt doch, dass es 8 Byte also 64 Bit groß ist und damit meine max 33 Bit-Zahl darstellen soltte oder? Wo könnte der Fehler sein?</p>
<p>Ein</p>
<pre><code class="language-cpp">unsigned long long pts = (long long)(8589934591);
</code></pre>
<p>bringt</p>
<pre><code>error: integer constant is too large for &quot;long&quot; type
</code></pre>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1011140</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1011140</guid><dc:creator><![CDATA[dmh]]></dc:creator><pubDate>Tue, 07 Mar 2006 22:52:27 GMT</pubDate></item><item><title><![CDATA[Reply to [Gelöst] 33bit Zahl mit c&#x2F;c++ on Tue, 07 Mar 2006 23:00:12 GMT]]></title><description><![CDATA[<p>printf(&quot;%d&quot;) war nicht richtig. Mit printf(&quot;%lld&quot;) und unsigned long long pts = 8589934591LL; funktioniert es nun.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1011146</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1011146</guid><dc:creator><![CDATA[dmh]]></dc:creator><pubDate>Tue, 07 Mar 2006 23:00:12 GMT</pubDate></item><item><title><![CDATA[Reply to [Gelöst] 33bit Zahl mit c&#x2F;c++ on Tue, 07 Mar 2006 23:50:32 GMT]]></title><description><![CDATA[<p>das problem war nicht primär die falsche formatierung von printf, sondern dass die zahl direkt im quellcode stand. ohne zusätze interpretiert c++ sowas als int oder long und dafür ist sie natürlich zu groß.</p>
<p>schlag&quot;worte&quot; wie 'f' oder 'L' hinter einer zahl sagen dem compiler, um was für eine art konstante es sich handelt und er kann entsprechend speicher reservieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1011170</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1011170</guid><dc:creator><![CDATA[thordk]]></dc:creator><pubDate>Tue, 07 Mar 2006 23:50:32 GMT</pubDate></item><item><title><![CDATA[Reply to [Gelöst] 33bit Zahl mit c&#x2F;c++ on Wed, 08 Mar 2006 07:41:28 GMT]]></title><description><![CDATA[<p>camel filter schrieb:</p>
<blockquote>
<p>int und long int sind in der regel gleich groß, beide 32-bit. int ist zwar nur als 16-bit garantiert</p>
</blockquote>
<p>Das mag in C so sein, aber nicht in C++. Dort sind keine konkreten Grössen festgelegt, lediglich Relationen. Also dass zB int mindestens immer so gross ist wie long.</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/11032">@dmh</a><br />
Ganzzahlliterale ohne irgendwelche Zusätze sind immer erstmal vom Typ int. Durch entsprechende Suffixe kannst du daraus aber auch Literale eines anderen Typs machen. Und bedenke, long long ist kein C++ Typ, sondern lediglich eine Erweiterung deines Compilers.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1011236</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1011236</guid><dc:creator><![CDATA[groovemaster]]></dc:creator><pubDate>Wed, 08 Mar 2006 07:41:28 GMT</pubDate></item><item><title><![CDATA[Reply to [Gelöst] 33bit Zahl mit c&#x2F;c++ on Wed, 08 Mar 2006 07:46:06 GMT]]></title><description><![CDATA[<p>groovemaster schrieb:</p>
<blockquote>
<p>camel filter schrieb:</p>
<blockquote>
<p>int und long int sind in der regel gleich groß, beide 32-bit. int ist zwar nur als 16-bit garantiert</p>
</blockquote>
<p>Das mag in C so sein, aber nicht in C++. Dort sind keine konkreten Grössen festgelegt, lediglich Relationen. Also dass zB int mindestens immer so gross ist wie long.</p>
</blockquote>
<p>umgekehrt: long ist mindestens so groß wie int <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="😉"
    /> (und int ist mindestens 16 Bit groß)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1011241</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1011241</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Wed, 08 Mar 2006 07:46:06 GMT</pubDate></item><item><title><![CDATA[Reply to [Gelöst] 33bit Zahl mit c&#x2F;c++ on Wed, 08 Mar 2006 07:53:34 GMT]]></title><description><![CDATA[<p>Yep, das mit int und long muss natürlich andersrum lauten.</p>
<p>CStoll schrieb:</p>
<blockquote>
<p>und int ist mindestens 16 Bit groß</p>
</blockquote>
<p>Quellen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1011247</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1011247</guid><dc:creator><![CDATA[groovemaster]]></dc:creator><pubDate>Wed, 08 Mar 2006 07:53:34 GMT</pubDate></item><item><title><![CDATA[Reply to [Gelöst] 33bit Zahl mit c&#x2F;c++ on Wed, 08 Mar 2006 09:56:09 GMT]]></title><description><![CDATA[<p>steht so im ansi-c standard. int muss mindestens 2 byte gross sein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1011317</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1011317</guid><dc:creator><![CDATA[balla]]></dc:creator><pubDate>Wed, 08 Mar 2006 09:56:09 GMT</pubDate></item><item><title><![CDATA[Reply to [Gelöst] 33bit Zahl mit c&#x2F;c++ on Wed, 08 Mar 2006 10:08:56 GMT]]></title><description><![CDATA[<p>groovemaster schrieb:</p>
<blockquote>
<p>Das mag in C so sein, aber nicht in C++. Dort sind keine konkreten Grössen festgelegt, lediglich Relationen.</p>
</blockquote>
<p>Das ist in C exakt genauso wie in C++.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1011338</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1011338</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Wed, 08 Mar 2006 10:08:56 GMT</pubDate></item></channel></rss>