<?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[Warum ergibt das double bzw 1?]]></title><description><![CDATA[<p>Hallo zusammen,<br />
zwar habe ich einen ähnlichen Thread am Laufen, doch denke ich, dass dies eine neue Überschrift verdient. Es geht um ein konkretes Beispiel der Typumwandlung.</p>
<pre><code class="language-cpp">float x = 2.1f;
</code></pre>
<pre><code class="language-cpp">x + 2 // Dies ergibt float, denn 2 wird zu int konvertiert!!??
</code></pre>
<pre><code class="language-cpp">x * 2.0 //Warum ergibt dies double? float nimmt doch auch Kommazahlen auf? 2.0 ist also für float ideal und müsste doch gar nicht konvertiert werden?
</code></pre>
<p>Könnt ihr mir helfen?</p>
<p>Vielen Dank<br />
lg, freakC++</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/248853/warum-ergibt-das-double-bzw-1</link><generator>RSS for Node</generator><lastBuildDate>Wed, 16 Sep 2026 18:16:10 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/248853.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 30 Aug 2009 11:23:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Warum ergibt das double bzw 1? on Sun, 30 Aug 2009 12:44:04 GMT]]></title><description><![CDATA[<p>Hallo zusammen,<br />
zwar habe ich einen ähnlichen Thread am Laufen, doch denke ich, dass dies eine neue Überschrift verdient. Es geht um ein konkretes Beispiel der Typumwandlung.</p>
<pre><code class="language-cpp">float x = 2.1f;
</code></pre>
<pre><code class="language-cpp">x + 2 // Dies ergibt float, denn 2 wird zu int konvertiert!!??
</code></pre>
<pre><code class="language-cpp">x * 2.0 //Warum ergibt dies double? float nimmt doch auch Kommazahlen auf? 2.0 ist also für float ideal und müsste doch gar nicht konvertiert werden?
</code></pre>
<p>Könnt ihr mir helfen?</p>
<p>Vielen Dank<br />
lg, freakC++</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1769196</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1769196</guid><dc:creator><![CDATA[freakC++]]></dc:creator><pubDate>Sun, 30 Aug 2009 12:44:04 GMT</pubDate></item><item><title><![CDATA[Reply to Warum ergibt das double bzw 1? on Sun, 30 Aug 2009 11:27:49 GMT]]></title><description><![CDATA[<p>2.0 ist ein double-Wert. Und damit's keine Genauigkeitsverluste gibt, kommt bei float*double eben double raus. x*2.0f ist float*float =&gt; float.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1769200</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1769200</guid><dc:creator><![CDATA[Badestrand]]></dc:creator><pubDate>Sun, 30 Aug 2009 11:27:49 GMT</pubDate></item><item><title><![CDATA[Reply to Warum ergibt das double bzw 1? on Sun, 30 Aug 2009 11:30:11 GMT]]></title><description><![CDATA[<p>Soweit ich weis, wird das Ergebnis einer Rechnung immer als der Variablentyp behandelt, der die größte genauigkeit hat:</p>
<pre><code class="language-cpp">im ersten Fall entspräche das:
float &gt; int, also

static_cast&lt;float&gt;(  x + static_cast&lt;float&gt;(2)  );

im zweiten fall double &gt; float, also

static_cast&lt;double&gt;(   static_cast&lt;double&gt;(x)    *   2.0   );
</code></pre>
<p>würdest du 2.0f statt 2.0 schreiben, bliebe alles bei float. 2.0 ist nunmal double</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1769202</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1769202</guid><dc:creator><![CDATA[Gilder]]></dc:creator><pubDate>Sun, 30 Aug 2009 11:30:11 GMT</pubDate></item><item><title><![CDATA[Reply to Warum ergibt das double bzw 1? on Sun, 30 Aug 2009 11:31:47 GMT]]></title><description><![CDATA[<p>ich denke mal das hängt einfach von der zahl der nachkommastellen ab:<br />
2.1*2.0=4.20;--&gt;2 nachkommastellen--&gt;double<br />
2.1+2=4.1;--&gt;1 Nachkommastelle--&gt;float</p>
<p>um nicht unnötig genauigkeit zu verlieren nimmt das programm halt mal double da passt das ergebnis sicher ein.</p>
<p>mfg,<br />
andi01.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1769204</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1769204</guid><dc:creator><![CDATA[andi01]]></dc:creator><pubDate>Sun, 30 Aug 2009 11:31:47 GMT</pubDate></item><item><title><![CDATA[Reply to Warum ergibt das double bzw 1? on Sun, 30 Aug 2009 12:29:10 GMT]]></title><description><![CDATA[<p>Aber das würde bedeuten, dass float nur eine Nachkommastelle hat und das ist ja sicherlich nicht der Fall.</p>
<p>Kann man sagen, dass bei diser Schreibweise:</p>
<p>2.0<br />
3.0<br />
9.0</p>
<p>automatisch der Typ double verwendet wird. Wenn ich diese Zahl als float haben möchte, dann muss ich das direkt forder:</p>
<p>float a=2.0;</p>
<p>Vielen Dank<br />
lg, freakC++</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1769233</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1769233</guid><dc:creator><![CDATA[freakC++]]></dc:creator><pubDate>Sun, 30 Aug 2009 12:29:10 GMT</pubDate></item><item><title><![CDATA[Reply to Warum ergibt das double bzw 1? on Sun, 30 Aug 2009 12:37:49 GMT]]></title><description><![CDATA[<p>Könnt ihr zwei nicht lesen? Schaut Euch nochmal die erste Antwort von Badestrand an.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1769243</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1769243</guid><dc:creator><![CDATA[Sebastian Pizer]]></dc:creator><pubDate>Sun, 30 Aug 2009 12:37:49 GMT</pubDate></item><item><title><![CDATA[Reply to Warum ergibt das double bzw 1? on Sun, 30 Aug 2009 12:43:15 GMT]]></title><description><![CDATA[<p>Doch ich kann lesen nur das Problem ist, dass ich zwei verschiedenen Antworten bekomme. Daher habe ich einfach nochmal nachgefragt, denn ich möchte nichts falsches lernen.</p>
<p>Naja, da Du ja auch für Badestrands Antwort plädierst, werde ich mir diese nun verinnerlichen!</p>
<p>Vielen Dank<br />
lg, freakC++</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1769247</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1769247</guid><dc:creator><![CDATA[freakC++]]></dc:creator><pubDate>Sun, 30 Aug 2009 12:43:15 GMT</pubDate></item><item><title><![CDATA[Reply to Warum ergibt das double bzw 1? on Sun, 30 Aug 2009 12:44:05 GMT]]></title><description><![CDATA[<blockquote>
<p>2.0<br />
3.0<br />
9.0</p>
<p>automatisch der Typ double verwendet wird. Wenn ich diese Zahl als float haben möchte, dann muss ich das direkt forder:</p>
</blockquote>
<p>Flieskommazahlen, welche kein Suffix (f) haben, werden als double angenommen.</p>
<p>Wenn du float haben willst, dann mit dem entsprechenen Suffix:</p>
<pre><code class="language-cpp">2.0f; //float
2.0; //double
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1769248</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1769248</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Sun, 30 Aug 2009 12:44:05 GMT</pubDate></item><item><title><![CDATA[Reply to Warum ergibt das double bzw 1? on Sun, 30 Aug 2009 12:46:25 GMT]]></title><description><![CDATA[<p>Alles klar, dann habe ich das kapiert!!</p>
<p>Es bleibt aber noch eine Frage, weshalb ich den Titel des Threads auch geändert habe:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
using namespace std;
#define square(a) ((a) * (a))

int main()
{
	char m = (char)square(16);
	cout &lt;&lt; m+1 &lt;&lt; endl;

	return 0;
}
</code></pre>
<p>Warum kommt hier 1 heraus? m hat den Wert 127, aber ich dachte, dass dies gar nicht mehr im Wertebereich eines char liegts. Oder liegt es daran, dass char auch größer sein kann, aber 8 bits auf jeden Fall da sind?</p>
<p>Eine ASCII Tabelle kann mir da aber auch nicht helfen...warum kommt 1 heraus?</p>
<p>Vielen Dank<br />
lg, freakC++</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1769250</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1769250</guid><dc:creator><![CDATA[freakC++]]></dc:creator><pubDate>Sun, 30 Aug 2009 12:46:25 GMT</pubDate></item><item><title><![CDATA[Reply to Warum ergibt das double bzw 1? on Sun, 30 Aug 2009 13:02:24 GMT]]></title><description><![CDATA[<p>Wertebereich von char: -128 - + 127 (msvc++08 signed)</p>
<p>Du weist 256 zu, was dazu führt, dass char überläuft:<br />
bei &quot;128&quot; wird es zu -128 und die restlichen 128 kommen noch dazu und ergeben 0 und das + 1 = 1</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1769258</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1769258</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Sun, 30 Aug 2009 13:02:24 GMT</pubDate></item><item><title><![CDATA[Reply to Warum ergibt das double bzw 1? on Sun, 30 Aug 2009 13:03:28 GMT]]></title><description><![CDATA[<p>Ein char kann nur 8 Bit fassen. Dein 16^2 ergibt 256, also binär 100000000. In ein char passt aber 00000000. <em>Das passt einfach nicht!</em> <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="😉"
    /> So, wenn du nun 00000000 gespeichert hast, und noch eins draufaddierst, bist du wo?</p>
<p>Wie du darauf kommst, dass m 127 hat, weiß ich nicht...</p>
<p>Und ein char fasst genau 8 Bit Daten, egal ob von 0-255 (unsigned) oder von (-128)-127.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1769260</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1769260</guid><dc:creator><![CDATA[_matze]]></dc:creator><pubDate>Sun, 30 Aug 2009 13:03:28 GMT</pubDate></item><item><title><![CDATA[Reply to Warum ergibt das double bzw 1? on Sun, 30 Aug 2009 13:55:21 GMT]]></title><description><![CDATA[<p>freakC++ schrieb:</p>
<blockquote>
<p>Es bleibt aber noch eine Frage, weshalb ich den Titel des Threads auch geändert habe:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
using namespace std;
#define square(a) ((a) * (a))

int main()
{
	char m = (char)square(16);
	cout &lt;&lt; m+1 &lt;&lt; endl;

	return 0;
}
</code></pre>
<p>Warum kommt hier 1 heraus? m hat den Wert 127,</p>
</blockquote>
<p>Hat es? Ich dachte, 16*16=256. Und die 256 passt nicht in einen 8bit-Character. Wir wissen auch nicht, ob char bei Dir vorzeichenbehaftet ist, oder nicht. Falls char vorzeichenlos und 8bittig ist, ist m=0. Falls char vorzeichenbehaftet ist, ist das Ergebnis <em>implementierungsabhängig</em> (sprich: Schau in der Dokumentation Deines Compilers nach, was er macht. Der Standard garantiert hier nichts).</p>
<p>Angenommen, Dein Compiler macht aus (char)(256) eine 0.</p>
<p>freakC++ schrieb:</p>
<blockquote>
<p>warum kommt 1 heraus?</p>
</blockquote>
<p>Offensichtlich, weil m 0 ist. Das Ergebnis von char+int ist auf jeden Fall int. Das Ergebnis von char+char <em>ist auch</em> ein int. Das liegt an der &quot;integral promotion&quot;. Die Ganzzahltypen char, signed char, unsigned char, short und unsigned short werden zu int konvertiert, wenn Du mit denen rechnen willst und ein int all die Werte darstellen kann. Wenn Du std::cout über den &lt;&lt; Operator einen int gibst, wird die Zahl textuell dargestellt ---&gt; &quot;1&quot;</p>
<p>Gruß,<br />
SP</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1769264</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1769264</guid><dc:creator><![CDATA[Sebastian Pizer]]></dc:creator><pubDate>Sun, 30 Aug 2009 13:55:21 GMT</pubDate></item><item><title><![CDATA[Reply to Warum ergibt das double bzw 1? on Sun, 30 Aug 2009 13:17:47 GMT]]></title><description><![CDATA[<p>_matze schrieb:</p>
<blockquote>
<p>Und ein char fasst genau 8 Bit Daten, egal ob von 0-255 (unsigned) oder von (-128)-127.</p>
</blockquote>
<p>Sorry, aber das ist falsch.<br />
1. Ein char kann aus mehr als 8 Bits bestehen<br />
2. Der Standard garantiert nicht, dass ein vorzeichenbehafteter char -128 darstellen kann. Das liegt daran, dass er das Zweierkomplement nicht vorschreibt. Demnach sind also auch alle logischen Bitoperationen auf vorzeichenbehafteten Ganzzahlen <em>implementierungsabhängig</em>.</p>
<p>Diese <a href="http://home.att.net/~jackklein/c/inttypes.html" rel="nofollow">Basics</a> sollten bei jedem sitzen.</p>
<p>Gruß,<br />
SP</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1769268</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1769268</guid><dc:creator><![CDATA[Sebastian Pizer]]></dc:creator><pubDate>Sun, 30 Aug 2009 13:17:47 GMT</pubDate></item><item><title><![CDATA[Reply to Warum ergibt das double bzw 1? on Sun, 30 Aug 2009 14:26:21 GMT]]></title><description><![CDATA[<p>imho ist nicht mal garantiert, was bei einem signed wert bei über-/unterlauf passiert... das ist imho nur bei unsigned garantiert...</p>
<p>bb</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1769298</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1769298</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Sun, 30 Aug 2009 14:26:21 GMT</pubDate></item><item><title><![CDATA[Reply to Warum ergibt das double bzw 1? on Sun, 30 Aug 2009 15:03:49 GMT]]></title><description><![CDATA[<p>Sebastian Pizer schrieb:</p>
<blockquote>
<p>_matze schrieb:</p>
<blockquote>
<p>Und ein char fasst genau 8 Bit Daten, egal ob von 0-255 (unsigned) oder von (-128)-127.</p>
</blockquote>
<p>Sorry, aber das ist falsch.<br />
1. Ein char kann aus mehr als 8 Bits bestehen<br />
2. Der Standard garantiert nicht, dass ein vorzeichenbehafteter char -128 darstellen kann. Das liegt daran, dass er das Zweierkomplement nicht vorschreibt. Demnach sind also auch alle logischen Bitoperationen auf vorzeichenbehafteten Ganzzahlen <em>implementierungsabhängig</em>.</p>
<p>Diese <a href="http://home.att.net/~jackklein/c/inttypes.html" rel="nofollow">Basics</a> sollten bei jedem sitzen.</p>
<p>Gruß,<br />
SP</p>
</blockquote>
<p>Ein Byte ist heute nun einmal 8 Bit groß. Die variable Festlegung im Standard entstammt dem C Standard und als dieser festgelegt wurde war das noch nicht der Fall bzw. absehbar. _matze weiß das bestimmt, aber wenn man wirklich Probleme lösen will (hier die des TOs) muss man halt schauen wie es in der Realität aussieht, ausschließlich dem Standard folgend kann nicht begründet werden warum eine 1 heraus kommt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1769314</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1769314</guid><dc:creator><![CDATA[Realistiker]]></dc:creator><pubDate>Sun, 30 Aug 2009 15:03:49 GMT</pubDate></item><item><title><![CDATA[Reply to Warum ergibt das double bzw 1? on Sun, 30 Aug 2009 15:51:22 GMT]]></title><description><![CDATA[<p>Realistiker schrieb:</p>
<blockquote>
<p>[...bla über 8-Bit-Bytes...]</p>
</blockquote>
<p>Das ist ja alles schön und gut. Wenn _matze einen entsprechenden Qualifizierer wie &quot;in der Regel&quot; oder so benutzt hätte, hätte ich auch nicht gemeckert. Aber das hat er nicht. Meiner Meinung nach <em>kann man nicht zu wenig</em> darauf hinweisen, was der Standard garantiert und welche Freiheiten die Implementierungen haben. Das gilt ja nicht nur für char, sondern auch für andere Datentypen, sowie alle anderen Dinge, bei denen der Compiler freie Hand hat (copy elision, struct layout, empty class optimization, ...).</p>
<p>Realistiker schrieb:</p>
<blockquote>
<p>ausschließlich dem Standard folgend kann nicht begründet werden warum eine 1 heraus kommt.</p>
</blockquote>
<p>Auch wenn Du für eine Erklärung Implementierungsdetails &quot;erraten&quot; musst, ist das kein Grund zu behaupten, CHAR_BIT==8 wäre Gesetz.</p>
<p>Gruß,<br />
SP</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1769349</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1769349</guid><dc:creator><![CDATA[Sebastian Pizer]]></dc:creator><pubDate>Sun, 30 Aug 2009 15:51:22 GMT</pubDate></item><item><title><![CDATA[Reply to Warum ergibt das double bzw 1? on Sun, 30 Aug 2009 19:07:53 GMT]]></title><description><![CDATA[<p>Hey,<br />
vielen Dank für eure Antworten! Ihr habt mir echt geholfen!</p>
<p>Vielen Dank<br />
lg, freakC++</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1769459</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1769459</guid><dc:creator><![CDATA[freakC++]]></dc:creator><pubDate>Sun, 30 Aug 2009 19:07:53 GMT</pubDate></item><item><title><![CDATA[Reply to Warum ergibt das double bzw 1? on Sun, 30 Aug 2009 23:14:06 GMT]]></title><description><![CDATA[<p>Realistiker schrieb:</p>
<blockquote>
<p>Ein Byte ist heute nun einmal 8 Bit groß.</p>
</blockquote>
<p>Fail.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1769537</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1769537</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sun, 30 Aug 2009 23:14:06 GMT</pubDate></item><item><title><![CDATA[Reply to Warum ergibt das double bzw 1? on Mon, 31 Aug 2009 00:07:06 GMT]]></title><description><![CDATA[<p>Tim schrieb:</p>
<blockquote>
<p>Fail.</p>
</blockquote>
<p>Gegenbeispiel?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1769547</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1769547</guid><dc:creator><![CDATA[Nachfrager]]></dc:creator><pubDate>Mon, 31 Aug 2009 00:07:06 GMT</pubDate></item><item><title><![CDATA[Reply to Warum ergibt das double bzw 1? on Mon, 31 Aug 2009 00:23:12 GMT]]></title><description><![CDATA[<p><a href="http://www.parashift.com/c++-faq-lite/intrinsic-types.html#faq-26.4" rel="nofollow">http://www.parashift.com/c++-faq-lite/intrinsic-types.html#faq-26.4</a></p>
<p><a href="http://home.att.net/~jackklein/c/inttypes.html#char" rel="nofollow">http://home.att.net/~jackklein/c/inttypes.html#char</a></p>
<p><a href="http://en.wikipedia.org/wiki/Byte" rel="nofollow">http://en.wikipedia.org/wiki/Byte</a> (Unter History 2. )</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1769548</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1769548</guid><dc:creator><![CDATA[Gilder]]></dc:creator><pubDate>Mon, 31 Aug 2009 00:23:12 GMT</pubDate></item><item><title><![CDATA[Reply to Warum ergibt das double bzw 1? on Mon, 31 Aug 2009 09:26:04 GMT]]></title><description><![CDATA[<p>@Gilder<br />
Das ist schon klar. Das Wort Byte wird in vielen Zusammenhängen verwendet. Nur wie häufig arbeitest du mit einer C++ Umgebung in welcher ein Byte tatsächlich nicht 8 Bit breit ist?</p>
<p>Für das vom OP dargestellte Problem braucht man imho keine langen Erklärungsversuche aus dem Hut zaubern. Entweder 16 * 16 passt in seiner Umgebung in den Wertebereich eines char Typs oder wir haben an der Stelle UB und jede weitere Diskussion ist sinnlos, weil statt dem Ergebnis 1 beim nächsten Programmdurchlauf die Festplatte gelöscht werden könnte. <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>
<p>c++-faq-lite schrieb:</p>
<blockquote>
<p>[26.4] But, but, but what about machines where a char has more than 8 bits? Surely you're not saying a C++ byte might have more than 8 bits, are you?!?</p>
<p>Yep, that's right: a C++ byte might have more than 8 bits.</p>
<p>The C++ language guarantees a byte must always have at least 8 bits. But there are implementations of C++ that have more than 8 bits per byte</p>
</blockquote>
<p>Das ist imho nicht richtig. Der Standard sagt auch nicht, dass es mindestends 8 Bit sein müssen. Bei Gegendarstellung bitte die Stelle im Standard angeben. <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>
<p>ISO/IEC 14882 schrieb:</p>
<blockquote>
<p>1.7 The C + + memory model<br />
1 The fundamental storage unit in the C + + memory model is the byte. A byte is at least large enough to contain any member of the basic execution character set and is composed of a contiguous sequence of bits, the number of which is implementation-defined. The least significant bit is called the low-order bit; the most significant bit is called the high-order bit. The memory available to a C + + program consists of one or more sequences of contiguous bytes. Every byte has a unique address.</p>
</blockquote>
<p>Nachdem das <em>basic source character set</em> 96 Zeichen enthält und somit das <em>basic execution character set</em> 100 Zeichen, sind auch 7 Bit vorstellbar.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1769635</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1769635</guid><dc:creator><![CDATA[Nachfrager]]></dc:creator><pubDate>Mon, 31 Aug 2009 09:26:04 GMT</pubDate></item><item><title><![CDATA[Reply to Warum ergibt das double bzw 1? on Mon, 31 Aug 2009 09:52:45 GMT]]></title><description><![CDATA[<p>Die mathemtaische Begruendung ist: weil 1 == ( 16 * 16 + 1 ) mod 256. Und dein PC sowie Compiler halten sich an diese Arithmetik.</p>
<p>andi01 schrieb:</p>
<blockquote>
<p>ich denke mal das hängt einfach von der zahl der nachkommastellen ab:<br />
2.1*2.0=4.20;--&gt;2 nachkommastellen--&gt;double<br />
2.1+2=4.1;--&gt;1 Nachkommastelle--&gt;float</p>
<p>um nicht unnötig genauigkeit zu verlieren nimmt das programm halt mal double da passt das ergebnis sicher ein.</p>
<p>mfg,<br />
andi01.</p>
</blockquote>
<p>Unsinn! f'`8k</p>
<p><div class="plugin-markdown"><input type="checkbox" id="checkbox246209" /><label for="checkbox246209"></label></div><a href="http://tggc.tg.funpic.de/index.php?cat=8&amp;page=5" rel="nofollow">Autocogito</a></p>
<p>Gruß, TGGC (<a href="http://www.gamestar.de/index.cfm?pid=819&amp;pk=12279" rel="nofollow">Was Gamestar sagt...</a>)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1769650</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1769650</guid><dc:creator><![CDATA[TGGC]]></dc:creator><pubDate>Mon, 31 Aug 2009 09:52:45 GMT</pubDate></item><item><title><![CDATA[Reply to Warum ergibt das double bzw 1? on Mon, 31 Aug 2009 11:16:40 GMT]]></title><description><![CDATA[<p>Nachfrager schrieb:</p>
<blockquote>
<p>Für das vom OP dargestellte Problem braucht man imho keine langen Erklärungsversuche aus dem Hut zaubern. Entweder 16 * 16 passt in seiner Umgebung in den Wertebereich eines char Typs oder wir haben an der Stelle UB</p>
</blockquote>
<p>Nein, nicht UB, sondern implementation-defined.</p>
<p>Nachfrager schrieb:</p>
<blockquote>
<p>Der Standard sagt auch nicht, dass es mindestends 8 Bit sein müssen. Bei Gegendarstellung bitte die Stelle im Standard angeben. <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>
</blockquote>
<p>Siehe §18.2.2 &quot;C library&quot;, climits --&gt; limits.h, siehe ISO C Standard für limits.h:</p>
<blockquote>
<p>The values given below shall be replaced by constant expressions suitable for use in #if preprocessing directives. Moreover, except for CHAR_BIT and MB_LEN_MAX, the following shall be replaced by expressions that have the same type as would an expression that is an object of the corresponding type converted according to the integer promotions. <strong>Their implementation-defined values shall be equal or greater in magnitude (absolute value) to those shown, with the same sign</strong>.</p>
<ul>
<li>number of bits for smallest object that is not a bit field (byte)<br />
<strong>CHAR_BIT 8</strong></li>
<li>minimum value for an object of signed char<br />
SCHAR_MIN -127 // -(2^7-1)</li>
<li>maximum value for an object of signed char<br />
SCHAR_MAX 127 // 2^7-1</li>
<li>maximum value for an object of unsigned char<br />
<strong>UCHAR_MAX 255</strong> // 2^8-1</li>
<li>minimum value for an object of signed char<br />
CHAR_MIN <em>see below</em></li>
<li>maximum value for an object of signed char<br />
CHAR_MAX <em>see below</em></li>
</ul>
<p>...<br />
If the value of an object of type char is treated as a signed integer when used in an expression, the value of CHAR_MIN shall be the same as that of SCHAR_MIN and the value of CHAR_MAX shall be the same as that of SCHAR_MAX. Otherwise, the value of CHAR_MIN shall be 0 and the value of CHAR_MAX shall be the same as that of UCHAR_MAX. <strong>The value UCHAR_MAX shall equal 2^CHAR_BIT - 1</strong>.</p>
</blockquote>
<p>Mehr oder weniger 1:1 aus dem Standard steht das nochmal <a href="http://home.att.net/~jackklein/c/inttypes.html" rel="nofollow">hier</a>.</p>
<p>Gruß,<br />
SP</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1769653</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1769653</guid><dc:creator><![CDATA[Sebastian Pizer]]></dc:creator><pubDate>Mon, 31 Aug 2009 11:16:40 GMT</pubDate></item><item><title><![CDATA[Reply to Warum ergibt das double bzw 1? on Mon, 31 Aug 2009 10:34:48 GMT]]></title><description><![CDATA[<p>Sebastian Pizer schrieb:</p>
<blockquote>
<p>Auch wenn Du für eine Erklärung Implementierungsdetails &quot;erraten&quot; musst, ist das kein Grund zu behaupten, CHAR_BIT==8 wäre Gesetz.</p>
</blockquote>
<p>etwas später</p>
<p>Sebastian Pizer schrieb:</p>
<blockquote>
<p>Siehe §18.2.2 &quot;C library&quot;, climits --&gt; limits.h, siehe ISO C Standard für limits.h:</p>
<blockquote>
<p>...<br />
- number of bits for smallest object that is not a bit field (byte)<br />
CHAR_BIT 8</p>
</blockquote>
</blockquote>
<p>Hm ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1769665</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1769665</guid><dc:creator><![CDATA[Hinweiser]]></dc:creator><pubDate>Mon, 31 Aug 2009 10:34:48 GMT</pubDate></item><item><title><![CDATA[Reply to Warum ergibt das double bzw 1? on Mon, 31 Aug 2009 10:42:43 GMT]]></title><description><![CDATA[<p>Hinweiser schrieb:</p>
<blockquote>
<p>Sebastian Pizer schrieb:</p>
<blockquote>
<p>Auch wenn Du für eine Erklärung Implementierungsdetails &quot;erraten&quot; musst, ist das kein Grund zu behaupten, CHAR_BIT==8 wäre Gesetz.</p>
</blockquote>
<p>etwas später</p>
<p>Sebastian Pizer schrieb:</p>
<blockquote>
<p>Siehe §18.2.2 &quot;C library&quot;, climits --&gt; limits.h, siehe ISO C Standard für limits.h:</p>
<blockquote>
<p>...<br />
- number of bits for smallest object that is not a bit field (byte)<br />
CHAR_BIT 8</p>
</blockquote>
</blockquote>
<p>Hm ...</p>
</blockquote>
<p>Wo ist das Problem?</p>
<ol>
<li>CHAR_BIT == 8 ist nicht festgelegt.</li>
<li>CHAR_BIT &gt;= 8<br />
widerspricht sich nicht <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></li>
</ol>
]]></description><link>https://www.c-plusplus.net/forum/post/1769672</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1769672</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Mon, 31 Aug 2009 10:42:43 GMT</pubDate></item><item><title><![CDATA[Reply to Warum ergibt das double bzw 1? on Mon, 31 Aug 2009 10:48:01 GMT]]></title><description><![CDATA[<p>pumuckl schrieb:</p>
<blockquote>
<p>Wo ist das Problem?</p>
<ol>
<li>CHAR_BIT == 8 ist nicht festgelegt.</li>
<li>CHAR_BIT &gt;= 8<br />
widerspricht sich nicht <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></li>
</ol>
</blockquote>
<p>Hast Recht. Absätze vollständig zu lesen bringt einem manchmal weiter.:)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1769676</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1769676</guid><dc:creator><![CDATA[Hinweiser]]></dc:creator><pubDate>Mon, 31 Aug 2009 10:48:01 GMT</pubDate></item></channel></rss>