<?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[Frage zum &amp;quot;Rechnen&amp;quot; mit char]]></title><description><![CDATA[<p>Hallo. Gibt es irgendwelche Probleme, wenn ich mit char variablen rechne (also +, -, *, /, % ) oder kann man mit char genauso rechnen wie zB mit int? Und kann das Rechnen mit char in irgendwelchen Situationen schneller sein, als das Rechnen mit int?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/246330/frage-zum-quot-rechnen-quot-mit-char</link><generator>RSS for Node</generator><lastBuildDate>Fri, 18 Sep 2026 03:31:41 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/246330.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 26 Jul 2009 18:23:40 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Frage zum &amp;quot;Rechnen&amp;quot; mit char on Sun, 26 Jul 2009 18:23:40 GMT]]></title><description><![CDATA[<p>Hallo. Gibt es irgendwelche Probleme, wenn ich mit char variablen rechne (also +, -, *, /, % ) oder kann man mit char genauso rechnen wie zB mit int? Und kann das Rechnen mit char in irgendwelchen Situationen schneller sein, als das Rechnen mit int?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1749934</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1749934</guid><dc:creator><![CDATA[Enlong]]></dc:creator><pubDate>Sun, 26 Jul 2009 18:23:40 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zum &amp;quot;Rechnen&amp;quot; mit char on Sun, 26 Jul 2009 18:26:08 GMT]]></title><description><![CDATA[<p>mit char kann man genauso rechnen wie mit int. Das einzige was du beachten solltest ist das ein char eben nur 1 byte gross ist, also nur maximal 256 gross sein kann</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1749936</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1749936</guid><dc:creator><![CDATA[player4245]]></dc:creator><pubDate>Sun, 26 Jul 2009 18:26:08 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zum &amp;quot;Rechnen&amp;quot; mit char on Sun, 26 Jul 2009 19:09:56 GMT]]></title><description><![CDATA[<p>255</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1749948</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1749948</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Sun, 26 Jul 2009 19:09:56 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zum &amp;quot;Rechnen&amp;quot; mit char on Sun, 26 Jul 2009 19:49:22 GMT]]></title><description><![CDATA[<p>player4245 schrieb:</p>
<blockquote>
<p>Das einzige was du beachten solltest ist das ein char eben nur 1 byte gross ist, also nur maximal 256 gross sein kann</p>
</blockquote>
<p>Das ist nicht richtig! Ein char ist mindestens 8Bit groß, und es kann Vorzeichen behaftet sein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1749965</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1749965</guid><dc:creator><![CDATA[*john 0]]></dc:creator><pubDate>Sun, 26 Jul 2009 19:49:22 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zum &amp;quot;Rechnen&amp;quot; mit char on Sun, 26 Jul 2009 19:58:44 GMT]]></title><description><![CDATA[<p>auf allen x86 kompatiblen System ist es 8 Bit.</p>
<p>ob signed oder unsigned hängt von der Compilereinstellung ab.<br />
bei VC++ is default signed.</p>
<p>kurz: char reicht von -128 bis 127<br />
und unsigned char von 0 bis 255.</p>
<p>ansonsten kannst du, wie schon von meinen Vorrednern erwähnt, mit chars genau so rechnen, wie mit ints, shorts und longs...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1749969</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1749969</guid><dc:creator><![CDATA[DrakoXP]]></dc:creator><pubDate>Sun, 26 Jul 2009 19:58:44 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zum &amp;quot;Rechnen&amp;quot; mit char on Sun, 26 Jul 2009 20:01:05 GMT]]></title><description><![CDATA[<p>Ist es denn auch schneller? Weil bisher konnte ich keinen Geschwindigkeitsvorteil erkennen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1749972</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1749972</guid><dc:creator><![CDATA[Enlong]]></dc:creator><pubDate>Sun, 26 Jul 2009 20:01:05 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zum &amp;quot;Rechnen&amp;quot; mit char on Sun, 26 Jul 2009 20:03:44 GMT]]></title><description><![CDATA[<p>Enlong schrieb:</p>
<blockquote>
<p>Ist es denn auch schneller? Weil bisher konnte ich keinen Geschwindigkeitsvorteil erkennen</p>
</blockquote>
<p>wieso sollte es?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1749974</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1749974</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Sun, 26 Jul 2009 20:03:44 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zum &amp;quot;Rechnen&amp;quot; mit char on Sun, 26 Jul 2009 20:12:05 GMT]]></title><description><![CDATA[<p>hm, weil man nur 1/4 der Bits berabeiten muss? <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="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1749977</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1749977</guid><dc:creator><![CDATA[Enlong]]></dc:creator><pubDate>Sun, 26 Jul 2009 20:12:05 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zum &amp;quot;Rechnen&amp;quot; mit char on Sun, 26 Jul 2009 20:16:57 GMT]]></title><description><![CDATA[<p>Enlong schrieb:</p>
<blockquote>
<p>Ist es denn auch schneller? Weil bisher konnte ich keinen Geschwindigkeitsvorteil erkennen</p>
</blockquote>
<p>Nein, dein 32-Bit Rechner rechnet lieber mit 4Byte, statt mit Einem.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1749980</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1749980</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sun, 26 Jul 2009 20:16:57 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zum &amp;quot;Rechnen&amp;quot; mit char on Sun, 26 Jul 2009 20:18:47 GMT]]></title><description><![CDATA[<p>Es gibt 3 verschiedene Character-Typen: char, signed char, unsigned char.</p>
<p>signed char kann mindestens Zahlen aus dem Bereich -127...127 darstellen<br />
unsigned char kann mindestens Zahlen aus dem Bereich 0...255 darstellen</p>
<p>Der Typ char ähnelt entweder signed char oder unsigned char. Das ist aber Abhängig von der Implementierung.</p>
<p>Siehe <a href="http://home.att.net/~jackklein/c/inttypes.html" rel="nofollow">Integer Types in C and C++</a></p>
<p>Zusätzlich zu den C-Makros in &lt;climits&gt; gibt es noch die Traits-Klasse std::numeric_limits&lt;&gt; in &lt;limits&gt;, über die man Implementierungsdetails erfragen kann.</p>
<p>Und wenn die Rede von einem &quot;Byte&quot; ist, muss das nicht unbedingt ein &quot;Oktett&quot; sein.</p>
<p>Gruß,<br />
SP</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1749981</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1749981</guid><dc:creator><![CDATA[Sebastian Pizer]]></dc:creator><pubDate>Sun, 26 Jul 2009 20:18:47 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zum &amp;quot;Rechnen&amp;quot; mit char on Mon, 27 Jul 2009 09:35:10 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/36159">@Sebastian</a> Pizer</p>
<p>-&gt; -128 bis 127 <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/1750146</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1750146</guid><dc:creator><![CDATA[DrakoXP]]></dc:creator><pubDate>Mon, 27 Jul 2009 09:35:10 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zum &amp;quot;Rechnen&amp;quot; mit char on Mon, 27 Jul 2009 11:41:28 GMT]]></title><description><![CDATA[<p>DrakoXP schrieb:</p>
<blockquote>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/36159">@Sebastian</a> Pizer<br />
-&gt; -128 bis 127 <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>Was soll mir das sagen?</p>
<p>Tipp: Wenn Du glaubst, der Standard garantiere, signed char könne -128 halten, dann irrst Du Dich. Der Standard erlaubt auch andere Formen der Repräsentierung von vorzeichenbehafteten Ganzzahlen. Genauer: Zweierkomplement, Einerkomplement und Sign+Magnitude. Du kannst Dich also nicht einmal darauf verlassen, dass ~(-1)==0 gilt. Bei 8 Bits und Einerkomplement oder Sign+Magnitude ist -127 die kleinste Zahl, die darstellbar ist. Wenn Du eine beliebige Zahl zu einem signed [char,short,int,long] konvertierst, ist das Ergebnis nur wohldefiniert, wenn der Typ die Zahl auch darstellen kann. Der andere Fall ist implementierungsabhängig.</p>
<p>Worauf Du Dich verlassen kannst, ist, dass wenn Du eine beliebige Zahl x zu einem unsigned |char,short,int,long] y konvertierst, dass dann x = y mod 2^N gilt, wobei N die Anzahl der Bits in y ist.</p>
<p>Gruß,<br />
SP</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1750224</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1750224</guid><dc:creator><![CDATA[Sebastian Pizer]]></dc:creator><pubDate>Mon, 27 Jul 2009 11:41:28 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zum &amp;quot;Rechnen&amp;quot; mit char on Mon, 27 Jul 2009 19:06:46 GMT]]></title><description><![CDATA[<p>DrakoXP schrieb:</p>
<blockquote>
<p>auf allen x86 kompatiblen System ist es 8 Bit.</p>
</blockquote>
<p>Nein, auch darauf darfst Du dich nicht verlassen! Die Größe von char hängt vom jeweiligen OS ab, und daher muß man das vorher überprüfen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1750491</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1750491</guid><dc:creator><![CDATA[*john 0]]></dc:creator><pubDate>Mon, 27 Jul 2009 19:06:46 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zum &amp;quot;Rechnen&amp;quot; mit char on Mon, 27 Jul 2009 19:09:31 GMT]]></title><description><![CDATA[<p>~john schrieb:</p>
<blockquote>
<p>DrakoXP schrieb:</p>
<blockquote>
<p>auf allen x86 kompatiblen System ist es 8 Bit.</p>
</blockquote>
<p>Nein, auch darauf darfst Du dich nicht verlassen! Die Größe von char hängt vom jeweiligen OS ab, und daher muß man das vorher überprüfen.</p>
</blockquote>
<p>Oh, da muß ich jetzt aber jede Menge Software reparieren. Damits schneller geht, kannste mal kurz aufzählen, welche Betriebssysteme Dir so geläufig sind, wo ein Byte nicht 8 Bit hat?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1750492</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1750492</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Mon, 27 Jul 2009 19:09:31 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zum &amp;quot;Rechnen&amp;quot; mit char on Mon, 27 Jul 2009 19:17:32 GMT]]></title><description><![CDATA[<p>I sense great amounts of irony in here...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1750499</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1750499</guid><dc:creator><![CDATA[Enlong]]></dc:creator><pubDate>Mon, 27 Jul 2009 19:17:32 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zum &amp;quot;Rechnen&amp;quot; mit char on Mon, 27 Jul 2009 19:46:43 GMT]]></title><description><![CDATA[<p>volkard schrieb:</p>
<blockquote>
<p>Oh, da muß ich jetzt aber jede Menge Software reparieren. Damits schneller geht, kannste mal kurz aufzählen, welche Betriebssysteme Dir so geläufig sind, wo ein Byte nicht 8 Bit hat?</p>
</blockquote>
<p>Es geht mir darum, daß es so etwas wie die ISO Norm für C und C++ existieren. <strong>Wenn man annimmt, daß ein char exakt 8Bit groß ist, dann muß man das OS genauer spezifizieren.</strong> Im Falle der Single UNIX Spec (in Teilen ebenfalls eine ISO Norm) ist ein char immer 8bit groß. Bei Windows dürfte es ebenfalls so sein. Aber das ist keine allgemeingültige Aussage.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1750515</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1750515</guid><dc:creator><![CDATA[*john 0]]></dc:creator><pubDate>Mon, 27 Jul 2009 19:46:43 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zum &amp;quot;Rechnen&amp;quot; mit char on Mon, 27 Jul 2009 19:50:46 GMT]]></title><description><![CDATA[<p>~john schrieb:</p>
<blockquote>
<p>…</p>
</blockquote>
<p>P.S. Es gibt da draußen OS bei denen die unteren 7Bit in einem char nicht ASCII kodiert sein. Und diese Rechner sind keine Exoten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1750520</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1750520</guid><dc:creator><![CDATA[*john 0]]></dc:creator><pubDate>Mon, 27 Jul 2009 19:50:46 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zum &amp;quot;Rechnen&amp;quot; mit char on Mon, 27 Jul 2009 20:07:03 GMT]]></title><description><![CDATA[<p>hat sich erledigt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1750530</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1750530</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Mon, 27 Jul 2009 20:07:03 GMT</pubDate></item></channel></rss>